コード例 #1
0
        /// <summary>
        /// This method writes a new record to the database table for a regular time series.
        /// The method will record extra parameters (other than those that are saved
        /// as class-level properties of this object) into the database record using the strings
        /// in the method parameters extraParamNames and extraParamValues.  This method does not
        /// make any changes to the trace table.
        /// </summary>
        /// <param name="doWriteToDB">true if the method should actually save the timeseries to the database</param>
        /// <param name="tsImport">TSImport object into which the method will record values that it has computed.
        /// If this parameter is null, then the method will skip the recording of such paramters to an object.</param>
        /// <param name="timeStepUnit">TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, or Year</param>
        /// <param name="timeStepQuantity">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.</param>
        /// <param name="timeStepCount">The number of time steps in the time series</param>
        /// <param name="outStartDate">date of the first time step in the series</param>
        /// <param name="extraParamNames">A list of field names that the the method should fill, in addition
        /// to the fields that the TimeSeriesLibrary is designed to maintain.  Every item in this list must
        /// be matched to an item in extraParamValues.</param>
        /// <param name="extraParamValues">A list of field values that the the method should fill, in addition
        /// to the fields that the TimeSeriesLibrary is designed to maintain.  Every item in this list must
        /// be matched to an item in extraParamNames.</param>
        /// <returns>the primary key Id value of the new record that was created</returns>
        public unsafe int WriteParametersRegular(
            bool doWriteToDB, TSImport tsImport,
            short timeStepUnit, short timeStepQuantity,
            int timeStepCount, DateTime outStartDate,
            String extraParamNames, String extraParamValues)
        {
            ErrorCheckWriteValues(doWriteToDB, tsImport);
            // The method's parameters are used to compute the meta-parameters of this time series
            TSParameters.SetParametersRegular(
                (TSDateCalculator.TimeStepUnitCode)timeStepUnit, timeStepQuantity,
                timeStepCount, outStartDate,
                // new time series are always compressed by the current compression technique
                TSBlobCoder.currentCompressionCode);
            IsInitialized = true;
            // Compute the Checksum for this time series ensemble.  Because this is a newly
            // written series, there are not yet any traces to incorporate into the checksum
            // (presumably those will be added later).
            Checksum = TSBlobCoder.ComputeChecksum(TSParameters, new List <ITimeSeriesTrace>());
            // WriteParameters method will handle all of the database interaction
            if (doWriteToDB)
            {
                WriteParameters(extraParamNames, extraParamValues);
            }

            return(Id);
        }
コード例 #2
0
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="timeStepUnit">TSDateCalculator.TimeStepUnitCode value for Minute, Hour, Day,
 /// Week, Month, Year, or Irregular</param>
 /// <param name="timeStepQuantity">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.</param>
 /// <param name="blobStartDate">Date of the first time step in the BLOB</param>
 /// <param name="traceList">a list of trace object whose checksums have already been computed.</param>
 /// <returns>the Checksum as a byte[16] array</returns>
 public byte[] ComputeChecksum(
     TSDateCalculator.TimeStepUnitCode timeStepUnit, short timeStepQuantity,
     DateTime blobStartDate, List <ITimeSeriesTrace> traceList)
 {
     return(TSBlobCoder.ComputeChecksum(timeStepUnit, timeStepQuantity,
                                        blobStartDate, traceList));
 }
コード例 #3
0
        /// <summary>
        /// This computes a new value for the Checksum field of the parameters table.  It does not save
        /// this change to the database, but to a DataTable object.  It is assumed that method
        /// TSConnection.CommitNewTraceWrites will be called later in order to send the changes to the
        /// database. If parameter 'toWriteToDB' is false, then this method can simply save the
        /// new Checksum value to the object given in the 'tsImport' parameter.
        /// </summary>
        /// <param name="toWriteToDB">true if the method should actually
        /// save the timeseries to the database</param>
        /// <param name="tsImport">TSImport object into which the method will record values
        /// that it has computed. If this parameter is null, then the method will skip the recording
        /// of such paramters to an object.</param>
        private void UpdateParametersChecksum(Boolean toWriteToDB, TSImport tsImport)
        {
            // The collection in variable 'traceObjects' contains one item for each trace for this
            // time series.  The primary purpose of the list is to store the checksum for each trace,
            // since the checksum of the timeseries is computed from the list of checksums from each
            // of its traces.
            List <ITimeSeriesTrace> traceObjects;

            if (tsImport != null)
            {
                traceObjects = tsImport.TraceList;
            }
            else
            {
                traceObjects = TraceList;
            }

            // Compute the new checksum of the ensemble
            Checksum = TSBlobCoder.ComputeChecksum(TimeStepUnit, TimeStepQuantity,
                                                   BlobStartDate, traceObjects);
            if (toWriteToDB)
            {
                DataTable dataTable;
                // Attempt to get the existing DataTable object from the collection that is kept by
                // the TSConnection object.  If this fails, then we'll create a new DataTable.
                if (TSConnection.BulkCopyDataTables.TryGetValue(ParametersTableName, out dataTable) == false)
                {
                    // Create the DataTable object and add columns that match the columns
                    // of the database table.
                    dataTable = new DataTable();
                    dataTable.Columns.Add("Id", typeof(int));
                    dataTable.Columns.Add("Checksum", typeof(byte[]));
                    // Add the DataTable to a collection that is kept in the TSConnection object.
                    TSConnection.BulkCopyDataTables.Add(ParametersTableName, dataTable);
                }
                dataTable.Rows.Add(Id, Checksum);
            }
        }