//検査メモ履歴の取得 public static void GetStudyMemoHistory(StudyKey key, out List <StudyMemoItem> items) { items = new List <StudyMemoItem>(); using (var db = new TryDbConnection(settings)) { using (var cmd = db.CreateCommand()) { cmd.CommandText = "SELECT MemoDate,Memo,UserName FROM T_StudyMemoHistory WHERE StudyInstanceUID=@0 ORDER BY MemoDate DESC"; cmd.Add(key.StudyInstanceUID); using (var dr = cmd.ExecuteReader()) { while (dr.Read()) { var item = new StudyMemoItem(); item.Memo = (string)dr["Memo"]; item.UserName = (string)dr["UserName"]; item.MemoDate = (DateTime)dr["MemoDate"]; items.Add(item); } } } } }
public static bool SetStudyMemo(StudyKey key, StudyMemoItem item) { if (AppUtil.DbType == AppUtil.DB_CLD) { return(LCL.SetStudyMemo(key, item)); } else { throw new NotImplementedException(); } }
public static void GetStudyMemo(StudyKey key, out StudyMemoItem item, out int count) { if (AppUtil.DbType == AppUtil.DB_CLD) { LCL.GetStudyMemo(key, out item, out count); } else { throw new NotImplementedException(); } }
//検査メモの取得 public static void GetStudyMemo(StudyKey key, out StudyMemoItem item, out int histCount) { item = null; histCount = 0; using (var db = new TryDbConnection(settings)) { using (var cmd = db.CreateCommand()) { cmd.CommandText = "SELECT MemoDate,Memo,UserName FROM T_StudyMemo WHERE StudyInstanceUID=@0"; cmd.Add(key.StudyInstanceUID); using (var dr = cmd.ExecuteReader()) { if (dr.Read()) { item = new StudyMemoItem(); item.Memo = (string)dr["Memo"]; item.UserName = (string)dr["UserName"]; item.MemoDate = (DateTime)dr["MemoDate"]; } } } using (var cmd = db.CreateCommand()) { cmd.CommandText = "SELECT COUNT(*) cnt FROM T_StudyMemoHistory WHERE StudyInstanceUID=@0"; cmd.Add(key.StudyInstanceUID); using (var dr = cmd.ExecuteReader()) { if (dr.Read()) { histCount = Convert.ToInt32(dr["cnt"]); } } } } }
//検査メモの設定 public static bool SetStudyMemo(StudyKey key, StudyMemoItem item) { for (int i = 0; i < AppUtil.RetryCount; i++) { string err = ""; var now = DateTime.Now; using (var db = new TryDbConnection(settings)) { db.BeginTransaction(); try { using (var cmd = db.CreateCommand()) { cmd.CommandText = "DELETE FROM T_StudyMemo WHERE StudyInstanceUID=@0"; cmd.Add(key.StudyInstanceUID); cmd.ExecuteNonQuery(); } if (item.Memo.Trim() != "") { using (var cmd = db.CreateCommand()) { cmd.CommandText = "INSERT INTO T_StudyMemo(StudyInstanceUID,MemoDate,Memo,UserName) VALUES(@0,@1,@2,@3)"; cmd.Add(key.StudyInstanceUID); cmd.Add(now); cmd.Add(item.Memo); cmd.Add(item.UserName); cmd.ExecuteNonQuery(); } } using (var cmd = db.CreateCommand()) { cmd.CommandText = "INSERT INTO T_StudyMemoHistory(StudyInstanceUID,MemoDate,Memo,UserName) VALUES(@0,@1,@2,@3)"; cmd.Add(key.StudyInstanceUID); cmd.Add(now); cmd.Add(item.Memo); cmd.Add(item.UserName); cmd.ExecuteNonQuery(); } db.Commit(); return(true); } catch (Exception ex) { db.Rollback(); err = ex.ToString(); } } //リトライ if (i < AppUtil.RetryCount - 1) { System.Threading.Thread.Sleep(AppUtil.SleepTime); } else { LogUtil.Error(err); } } return(false); }