public static void StoreDataTransaction(string NLPData, string UserData, string note_id, string is_complete) { List <Unidentified_TableModel> usrList = JsonConvert.DeserializeObject <List <Unidentified_TableModel> >(UserData); List <NLP_TableModel> nlpList = JsonConvert.DeserializeObject <List <NLP_TableModel> >(NLPData); string sqlUnident = Unidentified_TableModel.Store_Unidentified_Data_SQL(usrList, note_id); using (SqlConnection conn = MedNotesConnection()) { using (SqlCommand cmd = conn.CreateCommand()) { using (SqlTransaction transaction = conn.BeginTransaction("Store_Data_Transaction")) { try { cmd.Transaction = transaction; // Save NLP SQL cmd.CommandText = NLP_TableModel.Store_NLPData_SQL(nlpList, note_id, is_complete); cmd.ExecuteNonQuery(); // Save User SQL cmd.CommandText = sqlUnident; cmd.ExecuteNonQuery(); transaction.Commit(); } catch (Exception ex_tran) { LogHelper.SaveLogInfo(string.Format("Exception: Store Data Transaction is failed: \r\n {0}", ex_tran), ex_tran.StackTrace); try { transaction.Rollback(); } catch (Exception ex_roll) { LogHelper.SaveLogInfo(string.Format("Exception: Rollback Exception: \r\n {0}", ex_roll), ex_roll.StackTrace); } } } } } }
public static List <NLP_TableModel> Get_NLP_HTML_Highlight(int note_id) { List <NLP_TableModel> result = new List <NLP_TableModel>(); using (SqlConnection conn = MedNotesConnection()) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = NLP_TableModel.Get_HTML_SQL; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@note_id ", System.Data.SqlDbType.Int) { Value = note_id }); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { result.Add(NLP_TableModel.HTML_NLP_FromDataReader(dr)); } } return(result); }