public void Post(string title, string content) { if (NewPost != null) { NewPost.Invoke(this, EventArgs.Empty); } }
public void Post(string title, string content) { //save the post _posts[title] = content; //notify the NewPost event subscribers //if (NewPost != null) //{ // NewPost.Invoke(this, EventArgs.Empty); //} NewPost?.Invoke(this, EventArgs.Empty); }
/// <summary> /// 각 사이트에서 새로운 알림이 올 경우 이 함수가 실행됩니다. /// </summary> /// <param name="postItem"></param> private void Site_NewPost(PostItem postItem) { // Database Article 테이블에 새로운 post의 tuple을 삽입해줌 MysqlNode node = new MysqlNode(GachonOption.MysqlOption, "INSERT INTO article (course_no, board_name, no, category, publisher, title, date, content, url, sitetype, siteid)" + "VALUES (?course_no, ?board_name, ?no, ?posttype, ?publisher, ?title, ?date, ?content, ?url, ?sitetype, ?siteid) "); //일반 게시글의 경우엔 강의번호, 게시판이름, 게시글번호 등의 attribute가 있음 node["course_no"] = this.Key; node["board_name"] = postItem.board_name; node["no"] = postItem.no; node["posttype"] = (int)postItem.posttype; node["publisher"] = postItem.Publisher; node["title"] = postItem.Title; node["date"] = postItem.time; node["content"] = postItem.Content; node["url"] = postItem.url; node["sitetype"] = postItem.source.Type; node["siteid"] = postItem.source.ID; node.ExecuteNonQuery(); // 게시판의 유형이 레포트 제출실일 경우 형식이 다름 if (postItem.posttype == BoardType.PostType.Homework) { // 과제에 관한 게시글은 따로 Homework Table에 저장한다. MysqlNode hwnode = new MysqlNode(GachonOption.MysqlOption, "INSERT INTO homework (course_no, article_no, start_date, end_date)" + "VALUES (?course_no, ?article_no, ?start_date, ?end_date) "); // 레포트 게시글이기 때문에 마감기한도 추가 hwnode["course_no"] = this.Key; hwnode["article_no"] = postItem.no; hwnode["start_date"] = postItem.s_time; hwnode["end_date"] = postItem.e_time; hwnode.ExecuteNonQuery(); } // 이 객체의 이벤트를 듣고있는 리스너에게 이벤트 메세지 전달. NewPost?.Invoke(this, postItem); }
/// <summary> /// 각 사이트에서 새로운 알림이 올 경우 이 함수가 실행됩니다. /// </summary> /// <param name="postItem"></param> private void Site_NewPost(PostItem postItem) { //여기에 SQL추가하기~ Insert MysqlNode node = new MysqlNode(GachonOption.MysqlOption, "INSERT INTO article (course_no, board_name, no, category, publisher, title, date, content, url, sitetype, siteid)" + "VALUES (?course_no, ?board_name, ?no, ?posttype, ?publisher, ?title, ?date, ?content, ?url, ?sitetype, ?siteid) "); node["course_no"] = this.Key; node["board_name"] = postItem.board_name; node["no"] = postItem.no; node["posttype"] = (int)postItem.posttype; node["publisher"] = postItem.Publisher; node["title"] = postItem.Title; node["date"] = postItem.time; node["content"] = postItem.Content; node["url"] = postItem.url; node["sitetype"] = postItem.source.Type; node["siteid"] = postItem.source.ID; node.ExecuteNonQuery(); if (postItem.posttype == BoardType.PostType.Homework) { MysqlNode hwnode = new MysqlNode(GachonOption.MysqlOption, "INSERT INTO homework (course_no, article_no, start_date, end_date)" + "VALUES (?course_no, ?article_no, ?start_date, ?end_date) "); hwnode["course_no"] = this.Key; hwnode["article_no"] = postItem.no; hwnode["start_date"] = postItem.s_time; hwnode["end_date"] = postItem.e_time; hwnode.ExecuteNonQuery(); } // 이 객체의 이벤트를 듣고있는 리스너에게 이벤트 메세지 전달. NewPost?.Invoke(this, postItem); }
protected void NewPostEvent(PostItem item) { NewPost.Invoke(item); }