C# Class TimeSeriesLibrary.TSLibrary

This class contains the callable functions of the library for .NET code.
Mostrar archivo Open project: hydrologics/TimeSeriesLibrary Class Usage Examples

Public Methods

Method Description
CloseConnection ( int connectionNumber ) : void

Closes the connection identified with the given serial number. When the connection is closed, it is removed from the list of connections available to the time series library, and the serial number no longer refers to this connection.

ComputeChecksum ( TSDateCalculator timeStepUnit, short timeStepQuantity, System.DateTime blobStartDate, List traceList ) : byte[]

This method computes a Checksum for the timeseries. The input to the hash includes the list of parameters of the time series, and the list of checksums for each of the traces in the time series ensemble. The list of the traces' checksums are passed to this method within a list of ITimeSeriesTrace objects. This method does not modify the object given in the traceList parameter or assign any property values to any of its items.

ConvertBlobToListAll ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, Byte blobData, List &dateValueList, int compressionCode ) : int

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method converts the entire BLOB into the list. The sibling method ConvertBlobToListLimited can convert a selected portion of the BLOB into the list.

ConvertBlobToListLimited ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, int nReqValues, System.DateTime reqStartDate, System.DateTime reqEndDate, Byte blobData, List &dateValueList, int compressionCode ) : int

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method takes parameters for a maximum number of values, an earliest date, and a latest date, so that only a portion of the BLOB might be converted to the List. The sibling method ConvertBlobToListAll can convert the entire BLOB without any limits.

ConvertListToBlobWithChecksum ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, System.DateTime blobEndDate, List dateValueList, ITimeSeriesTrace traceObject, int &compressionCode ) : byte[]

This method converts a List of TimeSeriesValue objects into a BLOB (byte array) of time series values and computes a checksum from the BLOB. This method assigns the new values of the ValueBlob, Checksum, EndDate, and TimeStepCount to the object given in the traceObject parameter. The TraceNumber property of the traceObject parameter must be set before calling this method. The entire List is converted into the BLOB--i.e., the method does not take any parameters for limiting the size of the List that is created. This method will throw exceptions if the meta-parameters that are passed in are not consistent with the List of TimeSeriesValue objects.

CountTimeSteps ( System.DateTime startDate, System.DateTime endDate, short unit, short stepSize ) : int
DeleteMatchingSeries ( int connectionNumber, String tableName, String traceTableName, String whereClause ) : bool

This method deletes any records from the table which match the given WHERE clause of a SQL command, using the given database connection number and database table name.

DeleteSeries ( int connectionNumber, String tableName, String traceTableName, int id ) : bool

This method deletes a record for a single time series from the database, using the given database connection number and database table name.

FillDateArray ( TSDateCalculator timeStepUnit, short timeStepQuantity, int nReqValues, System.DateTime dateArray, System.DateTime reqStartDate ) : void
FillSeriesDateArray ( int connectionNumber, String tableName, String traceTableName, int id, int nReqValues, System.DateTime dateArray, System.DateTime reqStartDate ) : void
GetConnectionFromId ( int connectionNumber ) : SqlConnection

Returns the SqlConnection object corresponding to the given connection number.

IncrementDate ( System.DateTime startDate, TSDateCalculator unit, short stepSize, int numSteps ) : System.DateTime
OpenConnection ( String connectionString ) : int

Opens a new connection for the time series library to use. The new connection is added to a list and assigned a serial number within the list. The method returns the serial number of the new connection.

XmlImport ( String xmlFileName, List tsImportList ) : int

This method reads the given XML file and stores each time series that is defined in the XML file to a new TSImport object that is added to the given List of TSImport objects.

XmlImportAndSaveToDB ( int connectionNumber, String tableName, String traceTableName, String xmlFileName, List tsImportList ) : int

This method reads the given XML file and stores any time series that are defined in the XML file to the database using the given database connection number and database table name. Each time series is also stored in a new TSImport object that is addded to the given List of TSImport objects.

XmlImportFromString ( String xmlString, List tsImportList ) : int

This method reads the given XML string and stores each time series that is defined in the XML file to a new TSImport object that is added to the given List of TSImport objects.

Private Methods

Method Description
ConvertBlobToList ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, System.Boolean applyLimits, int nReqValues, System.DateTime reqStartDate, System.DateTime reqEndDate, Byte blobData, List &dateValueList, int compressionCode ) : int

This private method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method takes parameters for a maximum number of values, an earliest date, and a latest date, so that only a portion of the BLOB might be converted to the List. This method is designed to do the operations that are common between the public methods ConvertBlobToListLimited() and ConvertBlobToListAll().

Method Details

CloseConnection() public method

Closes the connection identified with the given serial number. When the connection is closed, it is removed from the list of connections available to the time series library, and the serial number no longer refers to this connection.
public CloseConnection ( int connectionNumber ) : void
connectionNumber int The serial number of the connection to be closed
return void

ComputeChecksum() public method

This method computes a Checksum for the timeseries. The input to the hash includes the list of parameters of the time series, and the list of checksums for each of the traces in the time series ensemble. The list of the traces' checksums are passed to this method within a list of ITimeSeriesTrace objects. This method does not modify the object given in the traceList parameter or assign any property values to any of its items.
public ComputeChecksum ( TSDateCalculator timeStepUnit, short timeStepQuantity, System.DateTime blobStartDate, List traceList ) : byte[]
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6.
blobStartDate System.DateTime Date of the first time step in the BLOB
traceList List a list of trace object whose checksums have already been computed.
return byte[]

ConvertBlobToListAll() public method

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method converts the entire BLOB into the list. The sibling method ConvertBlobToListLimited can convert a selected portion of the BLOB into the list.
public ConvertBlobToListAll ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, Byte blobData, List &dateValueList, int compressionCode ) : int
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6. If timeStepUnit is /// Irregular, then this value is ignored.
timeStepCount int the number of time steps that are stored in the blob
blobStartDate System.DateTime The DateTime value of the first time step in the BLOB. If /// timeStepUnit is Irregular, then this value is ignored.
blobData Byte The BLOB (byte array) that this method will convert
dateValueList List The List of TimeSeriesValues that this method will create from the BLOB.
compressionCode int a generation number that indicates what compression technique to use
return int

ConvertBlobToListLimited() public method

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method takes parameters for a maximum number of values, an earliest date, and a latest date, so that only a portion of the BLOB might be converted to the List. The sibling method ConvertBlobToListAll can convert the entire BLOB without any limits.
public ConvertBlobToListLimited ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, int nReqValues, System.DateTime reqStartDate, System.DateTime reqEndDate, Byte blobData, List &dateValueList, int compressionCode ) : int
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6. If timeStepUnit is /// Irregular, then this value is ignored.
timeStepCount int the number of time steps that are stored in the blob
blobStartDate System.DateTime The DateTime value of the first time step in the BLOB. If /// timeStepUnit is Irregular, then this value is ignored.
nReqValues int The maximum number of time steps that should be added to dateValueList
reqStartDate System.DateTime The earliest date that will be added to dateValueList
reqEndDate System.DateTime The latest date that will be added to dateValueList
blobData Byte The BLOB (byte array) that this method will convert into a List
dateValueList List The List of TimeSeriesValues that this method will create from the BLOB.
compressionCode int a generation number that indicates what compression technique to use
return int

ConvertListToBlobWithChecksum() public method

This method converts a List of TimeSeriesValue objects into a BLOB (byte array) of time series values and computes a checksum from the BLOB. This method assigns the new values of the ValueBlob, Checksum, EndDate, and TimeStepCount to the object given in the traceObject parameter. The TraceNumber property of the traceObject parameter must be set before calling this method. The entire List is converted into the BLOB--i.e., the method does not take any parameters for limiting the size of the List that is created. This method will throw exceptions if the meta-parameters that are passed in are not consistent with the List of TimeSeriesValue objects.
public ConvertListToBlobWithChecksum ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, System.DateTime blobEndDate, List dateValueList, ITimeSeriesTrace traceObject, int &compressionCode ) : byte[]
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for /// Minute, Hour, Day, Week, Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6.
timeStepCount int The number of time steps stored in the BLOB
blobStartDate System.DateTime Date of the first time step in the BLOB
blobEndDate System.DateTime Date of the last time step in the BLOB
dateValueList List A List of TimeSeriesValue objects that will be converted to a BLOB
traceObject ITimeSeriesTrace an object which contains the a TraceNumber property that is used to /// compute the checksum. The computed BLOB and checksum are both saved to the appropriate properties /// of this object.
compressionCode int a generation number that indicates what compression technique to use
return byte[]

CountTimeSteps() public method

public CountTimeSteps ( System.DateTime startDate, System.DateTime endDate, short unit, short stepSize ) : int
startDate System.DateTime
endDate System.DateTime
unit short
stepSize short
return int

DeleteMatchingSeries() public method

This method deletes any records from the table which match the given WHERE clause of a SQL command, using the given database connection number and database table name.
public DeleteMatchingSeries ( int connectionNumber, String tableName, String traceTableName, String whereClause ) : bool
connectionNumber int The serial number of the connection that is used to access the time series
tableName String The name of the database table that time series will be deleted from
traceTableName String The name of the database table that stores the BLOB for a single trace
whereClause String The WHERE clause of a SQL command, not including the word WHERE. /// For example, to delete delete all records where Id > 55, use the text "Id > 55".
return bool

DeleteSeries() public method

This method deletes a record for a single time series from the database, using the given database connection number and database table name.
public DeleteSeries ( int connectionNumber, String tableName, String traceTableName, int id ) : bool
connectionNumber int The serial number of the connection that is used to access the time series
tableName String The name of the database table that time series will be deleted from
traceTableName String The name of the database table that stores the BLOB for a single trace
id int The ID identifying the record to delete
return bool

FillDateArray() public method

public FillDateArray ( TSDateCalculator timeStepUnit, short timeStepQuantity, int nReqValues, System.DateTime dateArray, System.DateTime reqStartDate ) : void
timeStepUnit TSDateCalculator
timeStepQuantity short
nReqValues int
dateArray System.DateTime
reqStartDate System.DateTime
return void

FillSeriesDateArray() public method

public FillSeriesDateArray ( int connectionNumber, String tableName, String traceTableName, int id, int nReqValues, System.DateTime dateArray, System.DateTime reqStartDate ) : void
connectionNumber int
tableName String
traceTableName String
id int
nReqValues int
dateArray System.DateTime
reqStartDate System.DateTime
return void

GetConnectionFromId() public method

Returns the SqlConnection object corresponding to the given connection number.
public GetConnectionFromId ( int connectionNumber ) : SqlConnection
connectionNumber int serial number of the connection within the collection
return System.Data.SqlClient.SqlConnection

IncrementDate() public method

public IncrementDate ( System.DateTime startDate, TSDateCalculator unit, short stepSize, int numSteps ) : System.DateTime
startDate System.DateTime
unit TSDateCalculator
stepSize short
numSteps int
return System.DateTime

OpenConnection() public method

Opens a new connection for the time series library to use. The new connection is added to a list and assigned a serial number within the list. The method returns the serial number of the new connection.
public OpenConnection ( String connectionString ) : int
connectionString String The connection string used to open the connection.
return int

XmlImport() public method

This method reads the given XML file and stores each time series that is defined in the XML file to a new TSImport object that is added to the given List of TSImport objects.
public XmlImport ( String xmlFileName, List tsImportList ) : int
xmlFileName String The file name (with path) of an XML file that defines one or more time series to import
tsImportList List A List of TSImport objects that the method adds to. One item is added to the List /// for each time series that is processed in the XML file. The List must already be instantiated before calling /// this method. The method does not change any items that are already in the List.
return int

XmlImportAndSaveToDB() public method

This method reads the given XML file and stores any time series that are defined in the XML file to the database using the given database connection number and database table name. Each time series is also stored in a new TSImport object that is addded to the given List of TSImport objects.
public XmlImportAndSaveToDB ( int connectionNumber, String tableName, String traceTableName, String xmlFileName, List tsImportList ) : int
connectionNumber int The serial number of the connection that is used to write to the database
tableName String The name of the database table that time series will be written to
traceTableName String The name of the database table that stores the BLOB for a single trace
xmlFileName String The file name (with path) of an XML file that defines one or more time series to import
tsImportList List A List of TSImport objects that the method adds to. One item is added to the List /// for each time series that is processed in the XML file. The List must already be instantiated before calling /// this method. The method does not change any items that are already in the List.
return int

XmlImportFromString() public method

This method reads the given XML string and stores each time series that is defined in the XML file to a new TSImport object that is added to the given List of TSImport objects.
public XmlImportFromString ( String xmlString, List tsImportList ) : int
xmlString String the string containing XML that defines one or more time series to import
tsImportList List A List of TSImport objects that the method adds to. One item is added to the List /// for each time series that is processed in the XML string. The List must already be instantiated before calling /// this method. The method does not change any items that are already in the List.
return int