Example #1
0
        public static bool GetEyeExperimentData(int experiment_record_ID, out EyeExperimentData[] experiment_data)
        {
            experiment_data = new EyeExperimentData[0];
            string[] experiment_table_names = Enum.GetNames(typeof(EyeExperimentType));

            if (_DatabaseInUse == DatabaseType.MySql)
            {
                foreach (string experiment_type in experiment_table_names)
                {
                    string string_of_select_experiment_data = "select `Time`,`MilliSecond`,`LeftEyeCoordX`,`LeftEyeCoordY`," + "`RightEyeCoordX`,`RightEyeCoordY`,`LeftRelocationCoordX`," +
                       "`LeftRelocationCoordY`, `RightRelocationCoordX`, `RightRelocationCoordY` from `" + experiment_type + "` where `ExperimentRecordID`='" +
                       experiment_record_ID.ToString() + "';";


                    DataSet dataset = MySql.MySqlHelper.ExecuteQuery(string_of_select_experiment_data);
                    if (dataset.Tables[0].Rows.Count == 0)
                        continue;

                    experiment_data = new EyeExperimentData[dataset.Tables[0].Rows.Count];
                    for (int i = 0; i < dataset.Tables[0].Rows.Count; i++)
                    {
                        DataRow row = dataset.Tables[0].Rows[i];
                        DataColumnCollection colums = dataset.Tables[0].Columns;

                        experiment_data[i].ExperimentRecordID = experiment_record_ID;
                        experiment_data[i].Time = DateTime.Parse(row[colums[0]].ToString());
                        experiment_data[i].MilliSecond = Convert.ToInt32(row[colums[1]].ToString());
                        experiment_data[i].LeftEyeCoordX = Convert.ToInt32(row[colums[2]].ToString());
                        experiment_data[i].LeftEyeCoordY = Convert.ToInt32(row[colums[3]].ToString());
                        experiment_data[i].RightEyeCoordX = Convert.ToInt32(row[colums[4]].ToString());
                        experiment_data[i].RightEyeCoordY = Convert.ToInt32(row[colums[5]].ToString());
                        experiment_data[i].LeftRelocationCoordX = Convert.ToInt32(row[colums[6]].ToString());
                        experiment_data[i].LeftRelocationCoordY = Convert.ToInt32(row[colums[7]].ToString());
                        experiment_data[i].RightRelocationCoordX = Convert.ToInt32(row[colums[8]].ToString());
                        experiment_data[i].RightRelocationCoordY = Convert.ToInt32(row[colums[9]].ToString());
                        experiment_data[i].Valid = Convert.ToInt32(row[colums[10]].ToString());

                    }

                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
Example #2
0
 //存储眼动实验数据
 public static bool SaveEyeExperimentData(EyeExperimentData experiment_data)
 {
     string string_of_save_experiment_data = string.Format("insert into `" + "eye" + experiment_data.EyeExpName + "` (`ExperimentRecordID`,`Time`,`MilliSecond`,`LeftEyeCoordX`," +
         "`LeftEyeCoordY`,`RightEyeCoordX`,`RightEyeCoordY`,`LeftRelocationCoordX`,`LeftRelocationCoordY`,`RightRelocationCoordX`,`RightRelocationCoordY`,`Valid`) " +
         "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}');",
         experiment_data.ExperimentRecordID.ToString(), experiment_data.Time.ToString(), experiment_data.MilliSecond.ToString(), experiment_data.LeftEyeCoordX.ToString(),
         experiment_data.LeftEyeCoordY.ToString(),
         experiment_data.RightEyeCoordX.ToString(), experiment_data.RightEyeCoordY.ToString(),
         experiment_data.LeftRelocationCoordX.ToString(), experiment_data.LeftRelocationCoordY.ToString(),
         experiment_data.RightRelocationCoordX.ToString(), experiment_data.RightRelocationCoordY.ToString(), experiment_data.Valid.ToString());
     if (_DatabaseInUse == DatabaseType.MySql)
     {
         if (MySql.MySqlHelper.ExecuteCommand(string_of_save_experiment_data) != 1)
             return false;
         return true;
     }
     else
     {
         return false;
     }
 }