static void Debug() { GachonClass.NewPost += GachonClass_NewPost; //가천대 학생 객체 만들기 (학교 아이디와 패스워드로 로그인) GachonUser a = GachonUser.GetObject(private_data.id, private_data.password); GachonUser c = GachonUser.GetObject(private_data.id, private_data.password); // 해당 학생 정보 출력 Console.WriteLine(a.ToString(true)); // b.Name b.Department b.Email b.Phone 등으로 참조 가능 //GachonCafe gachonCafe = new GachonCafe("135687"); // 컴퓨터 네트워크에 2개의 카페를 연결. //GachonObjects.AllClass["201809970002"].CombineSite(gachonCafe); //GachonObjects.AllClass["201809372002"].CombineSite(new GachonCafe("140663")); // GachonClass gachonClass = GachonClass.GetObject("소프트웨어", "soft"); //gachonClass.CombineSite(new NaverCafe("gachon2010")); a.CombineClass(GachonClass.GetObject("소프트웨어", "soft")); Console.WriteLine("\r\n\r\n서버에 등록된 모든 강의"); foreach (GachonClass gc in GachonObjects.AllClass.Values) { Console.WriteLine(gc.ToString()); } Console.WriteLine("\r\n\r\n"); GachonClass.AutoCrawlingDelay = 10; // (초단위) 3초에 한번씩 최신글을 확인 GachonClass.StartAutoCrawling = true; // 강의 최신글 크롤링 시작. Console.ReadKey(); //다른 키가 눌릴때까지 대기 // 다른키가 눌렸을 경우 오토크롤링 종료 GachonClass.StartAutoCrawling = false; }
/// <summary> /// 가천 라이브러리에서 새로운 게시글이 올라오면 이 함수를 이벤트로 실행시킵니다. /// </summary> /// <param name="gclass">게시글이 올라온 강의</param> /// <param name="postItem">게시글</param> public static void NewPost(GachonClass gclass, PostItem postItem) { MysqlNode node = new MysqlNode(private_data.mysqlOption, "SELECT * FROM keyword"); JArray array = new JArray(); string ignore_id = ""; using (node.ExecuteReader()) { while (node.Read()) { if (ignore_id == node.GetString("student_id")) { continue; } string keyword = node.GetString("keyword"); if (CheckValid(keyword, gclass.Title, postItem.Title)) { ignore_id = node.GetString("student_id"); PostSystem.SendPost( string.Format("[{0}] 새로운 게시글 등록", gclass.Title), string.Format("[게시글 정보]\r\n{0} - {1}\r\n\r\n{2}\r\n\r\nURL : {3}", postItem.Title, postItem.Publisher, postItem.Content, postItem.url), "admin_keyword", ignore_id , false); ESocket socket = GachonSocket.GetOnlineUser(ignore_id); if (socket != null) { if (User.Items.ContainsKey(socket)) { User.Items[socket].ToChatMessage("[" + gclass.Title + "] 에 새로운 게시글이 등록되었습니다.", ChatType.System); if (postItem.posttype == BoardType.PostType.Homework) { NetworkMessageList.AddHomework(socket, gclass.Title, postItem.Title, postItem.e_time); } } } } } } }
// 가천대 강의로부터 새로운 게시글이 등록될경우 이 함수가 실행됨. private static void GachonClass_NewPost(GachonClass gclass, PostItem postItem) { Console.WriteLine(String.Format("[알림 - {0}] {1} -> {2}", postItem.posttype.ToString(), gclass.Title, postItem.ToString())); Console.WriteLine("\t\t" + postItem.Content_Briefly + "\r\n"); // Console.WriteLine("[알림 - " + postItem.posttype.ToString() + "] " + gclass.Title + " -> " + postItem.ToString() + " || " + postItem.Content_Briefly); }