コード例 #1
0
        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);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static List <Unidentified_TableModel> Get_Unidentified_Records(int note_id)
        {
            List <Unidentified_TableModel> result = new List <Unidentified_TableModel>();

            using (SqlConnection conn = MedNotesConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = Unidentified_TableModel.Get_Unidentified_Data_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(Unidentified_TableModel.UnidentifiedDataFromDataReader(dr));
                }
            }

            return(result);
        }