/// <summary> /// Adds a DataSet from a Add Threaded /// </summary> /// <param name="cadd"></param> internal void AddDataSetThreaded(object addThreaded) { if (null == addThreaded) { return; } AddThreaded add = (AddThreaded)addThreaded; DataSet dataSet = add.dataSet; DataTable dataTable = dataSet.Tables[0]; DataRow dataRow;// = dataTable.Rows[i]; DataColumnCollection dataColumns = dataTable.Columns; try { for (int index = add.start, end = add.count; index < end; index++) { dataRow = dataTable.Rows[index]; DateTime recordDate = DateTime.SpecifyKind((DateTime)dataRow.Field <DateTime>(add.dateTimeField), DateTimeKind.Utc); if (recordDate.Month != monthInReview || recordDate.Year != yearInReview) { continue; } T recordData = dataRow.Field <T>(add.dataField); //add the data lock (add.data) { add.data[recordDate.Day - 1, recordDate.Hour, recordDate.Minute, recordDate.Second] = Operator.Add(add.data[recordDate.Day - 1, recordDate.Hour, recordDate.Minute, recordDate.Second], recordData); } } } catch { throw; } }
/// <summary> /// Adds a DataSet from a Add Threaded /// </summary> /// <param name="cadd"></param> internal void AddDataSetThreaded(object addThreaded) { if (null == addThreaded) { return; } AddThreaded add = (AddThreaded)addThreaded; DataSet dataSet = add.dataSet; DataTable dataTable = dataSet.Tables[0]; DataRow dataRow;// = dataTable.Rows[i]; DataColumnCollection dataColumns = dataTable.Columns; DataColumn dataColumn = null; string dataFieldName = add.dataField.ToLowerInvariant(); foreach (DataColumn tempCol in dataColumns) { if (tempCol.ColumnName.ToLowerInvariant() == dataFieldName) { dataColumn = tempCol; break; } else { continue; } } if (null == dataColumn) { return; } Type columnType = dataColumn.DataType; bool convertDouble = columnType.IsAssignableFrom(typeof(double)); bool convertInt = columnType.IsAssignableFrom(typeof(int)); bool convertString = columnType.IsAssignableFrom(typeof(string)); try { for (int index = add.start, end = add.count; index < end; index++) { dataRow = dataTable.Rows[index]; DateTime recordDate = DateTime.SpecifyKind(dataRow.Field <DateTime>(add.dateTimeField), DateTimeKind.Utc); double recordData = 0; //create a boxed version of the data object tempData = dataRow.ItemArray[dataColumn.Ordinal]; //if it is a supported type if (convertDouble) { recordData = (double)tempData; } else if (convertInt) { recordData = Convert.ToDouble((int)tempData); } else if (convertString) { //this is a stringType //Double Parse the value try { recordData = Double.Parse(tempData.ToString()); } catch { //this is not a double equatable value continue; } } else//skip unsupported types { continue; } //add the data lock (add.data) { add.data[recordDate.Day - 1, recordDate.Hour, recordDate.Minute, recordDate.Second] += recordData; } } } catch { throw; } }