/// <summary> /// Pushes the given study into the EJS database. /// </summary> internal static void SaveStudyMetaData(SqlConnection dBconnection, ejsSessionToken sessionToken, ejsStudyMetaData study, int parentAssignmentId) { SqlCommand command = new SqlCommand(); SqlDataReader reader = null; command.CommandTimeout = 60; try { command.Connection = dBconnection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "UploadAndSaveStudyMetaData"; command.Parameters.Add("UserId", SqlDbType.UniqueIdentifier).Value = sessionToken.UserId; command.Parameters.Add("Title", SqlDbType.NVarChar, 50).Value = study.Title; command.Parameters.Add("Description", System.Data.SqlDbType.NVarChar, 500).Value = study.Description; command.Parameters.Add("ParentAssignmentId", SqlDbType.Int).Value = parentAssignmentId; command.Parameters.Add("CreationDate", System.Data.SqlDbType.DateTime).Value = study.CreationDate; command.Parameters.Add("LastModifiedDate", System.Data.SqlDbType.DateTime).Value = study.LastModifiedDate; command.Parameters.Add("IsAvailable", System.Data.SqlDbType.Bit).Value = 1; command.Parameters.Add("CommentCount", SqlDbType.Int).Value = study.CommentCount; command.ExecuteNonQuery(); } finally { command.Dispose(); if (reader != null) { reader.Close(); reader.Dispose(); } } }
/// <summary> /// Gets all the studies asc. with the given assignment. /// </summary> internal static void GetStudiesForAssignment(SqlConnection dBconnection, ejsSessionToken sessionToken, ejsAssignment assignment, ref List <ejsStudyMetaData> result) { result.Clear(); SqlCommand command = new SqlCommand(); SqlDataReader reader = null; command.CommandTimeout = 60; try { command.Connection = dBconnection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "GetStudiesForAssignment"; command.Parameters.Add("UserId", SqlDbType.Int).Value = assignment.OriginalOwnerDbId; command.Parameters.Add("AssignmentId", SqlDbType.Int).Value = assignment.EJSDatabaseId; reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ejsStudyMetaData study = new ejsStudyMetaData(); study.Title = reader.GetString(1); study.Description = reader.GetString(2); study.ParentAssignmentId = reader.GetInt32(4); study.CreationDate = reader.GetDateTime(5); study.LastModifiedDate = reader.GetDateTime(6); study.IsAvailable = reader.GetBoolean(7); study.CommentCount = reader.GetInt32(8); result.Add(study); } } } finally { command.Dispose(); if (reader != null) { reader.Close(); reader.Dispose(); } } }