Beispiel #1
0
    /// <summary>
    /// This method saves the given collection of <see cref="RawData"/> into the
    /// given <see cref="SQLiteOgamaDataSet.RawdataDataTable"/>
    /// </summary>
    /// <param name="lstRawData">A <see cref="RawData"/> with the new samples.</param>
    /// <param name="subjectRawDataTable">The <see cref="SQLiteOgamaDataSet.RawdataDataTable"/> to be filled.</param>
    /// <returns><strong>True</strong> if successful otherwise <strong>false</strong>.</returns>
    public static bool SaveDataToTable(RawData[] lstRawData, SQLiteOgamaDataSet.RawdataDataTable subjectRawDataTable)
    {
      try
      {
        // Notify the beginning of adding rows to subjectRawDataTable
        subjectRawDataTable.BeginLoadData();

        foreach (RawData data in lstRawData)
        {
          // Save data into datarow.
          SQLiteOgamaDataSet.RawdataRow workRowRawData =
            subjectRawDataTable.NewRawdataRow();

          workRowRawData.SubjectName = data.SubjectName;
          workRowRawData.TrialSequence = data.TrialSequence;
          workRowRawData.Time = data.Time;

          if (!data.PupilDiaX.HasValue)
          {
            workRowRawData.SetPupilDiaXNull();
          }
          else
          {
            workRowRawData.PupilDiaX = data.PupilDiaX.Value;
          }

          if (!data.PupilDiaY.HasValue)
          {
            workRowRawData.SetPupilDiaYNull();
          }
          else
          {
            workRowRawData.PupilDiaY = data.PupilDiaY.Value;
          }

          if (!data.GazePosX.HasValue)
          {
            workRowRawData.SetGazePosXNull();
          }
          else
          {
            workRowRawData.GazePosX = data.GazePosX.Value;
          }

          if (!data.GazePosY.HasValue)
          {
            workRowRawData.SetGazePosYNull();
          }
          else
          {
            workRowRawData.GazePosY = data.GazePosY.Value;
          }

          if (!data.MousePosX.HasValue)
          {
            workRowRawData.SetMousePosXNull();
          }
          else
          {
            workRowRawData.MousePosX = data.MousePosX.Value;
          }

          if (!data.MousePosY.HasValue)
          {
            workRowRawData.SetMousePosYNull();
          }
          else
          {
            workRowRawData.MousePosY = data.MousePosY.Value;
          }

          if (!data.EventID.HasValue)
          {
            workRowRawData.SetEventIDNull();
          }
          else
          {
            workRowRawData.EventID = data.EventID.Value;
          }

          subjectRawDataTable.AddRawdataRow(workRowRawData);
        }

        subjectRawDataTable.EndLoadData();
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);

        return false;
      }

      return true;
    }