/// <summary> /// 태그아이디로 노트리스트 불러옴 /// </summary> /// <param name="tagId"></param> /// <returns></returns> public static List <NoteVO> GetNoteListByTagId(int tagId) { List <NoteVO> noteList = new List <NoteVO>(); using (OracleConnection conn = DbHelper.NewConnection()) { conn.Open(); //중복검사 String sql = $"select note_id from note_tag_map where tag_id = :TagId"; OracleCommand cmd = new OracleCommand { Connection = conn, CommandText = sql }; OracleParameter paramTagId = cmd.Parameters.Add("TagId", OracleDbType.Varchar2); paramTagId.Value = tagId; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { NoteVO note = new NoteVO(); note = NoteDAO.GetNotebyId(int.Parse(reader["note_id"].ToString())); noteList.Add(note); } reader.Close(); return(noteList); } }
public static Dictionary <int, object> GetShortcuts() { Dictionary <int, object> shortcutDic = new Dictionary <int, object>(); //키값으론 order를 넣는다. 리스트에는 Note or Notebook을 넣고 각각 id, title을 넣는다. //shortcut에서 orderby order로 모든 데이터를 긁어온 후 order를 키값으로 넣고 type과 id를 해당 value 넣는다. using (OracleConnection conn = DbHelper.NewConnection()) { conn.Open(); String sql = "SELECT * FROM shortcut ORDER BY ORDERS ASC"; OracleCommand cmd = new OracleCommand { Connection = conn, CommandText = sql }; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int order = int.Parse(reader["orders"].ToString()); int noteid = 0; int notebookid = 0; if (reader["noteid"] != DBNull.Value) { noteid = int.Parse(reader["noteid"].ToString()); } else if (reader["notebookid"] != DBNull.Value) { notebookid = int.Parse(reader["notebookid"].ToString()); } if (noteid != 0) //노트일경우 { NoteVO newNote = new NoteVO() { NoteId = noteid, Title = NoteDAO.GetNotebyId(noteid).Title }; shortcutDic.Add(order, newNote); } else if (notebookid != 0) //노트북일경우 { NoteBookVO newNoteBook = new NoteBookVO() { NoteBookId = notebookid, Name = NoteBookDAO.GetNoteBookbyId(notebookid).Name }; shortcutDic.Add(order, newNoteBook); } } reader.Close(); return(shortcutDic); } }