示例#1
0
        public Portal(string cookie, MainForm mainForm)
        {
            this.cookie = cookie;
            this.mainForm = mainForm;

            // board 초기화
            for (int i = 0; i < 10 * 10; i++)
            {
                board1[i] = new PortalBoard();
                board2[i] = new PortalBoard();
                board3[i] = new PortalBoard();
                board4[i] = new PortalBoard();
            }

            for (int i = 0; i < 3 * 10; i++)
            {
                new_board4[i] = new PortalBoard();
            }

            setBoard(board1, a1, 1, 3);
            setBoard(board2, a2, 1, 3);
            setBoard(board3, a3, 1, 3);
            setLastestBoard(1, 3);

            taskbarNotifier = new TaskbarNotifier();
            taskbarNotifier.SetBackgroundBitmap(new Bitmap(GetType(), "skin.bmp"), Color.FromArgb(255, 0, 255));
            taskbarNotifier.SetCloseBitmap(new Bitmap(GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), new Point(121, 13));
            taskbarNotifier.TitleRectangle = new Rectangle(30, 13, 80, 25);
            taskbarNotifier.ContentRectangle = new Rectangle(12, 30, 125, 72);
            taskbarNotifier.CloseClickable = true;
            taskbarNotifier.TitleClickable = false;
            taskbarNotifier.ContentClickable = true;
            taskbarNotifier.EnableSelectionRectangle = true;
            taskbarNotifier.KeepVisibleOnMousOver = true;
            taskbarNotifier.ReShowOnMouseOver = true;

            taskbarNotifier.Show("새 글 알리미", "\n포탈 공지의 새 글을\n 알려줍니다 :)", 500, 3000, 500);
        }
示例#2
0
        private int setNewLastestBoard()
        {
            int diffCount = 0;

            for (int i = 0; i < PAGENUM * 10; i++)
                new_board4[i] = new PortalBoard();

            for (int pageNum = 0; pageNum <= PAGENUM; pageNum++)
            {
                string url = "http://portal.unist.ac.kr/EP/web/collaboration/bbs/jsp/BB_MyBoardLst.jsp?nfirst=" + pageNum;
                if (!getResponse(url))
                    return 0;

                doc = (IHTMLDocument2)new HTMLDocument();
                doc.clear();
                doc.write(resResult);
                doc.close();

                IEnumerable<IHTMLElement> titles = ElementsByClass(doc, "ltb_left");
                IEnumerable<IHTMLElement> elements = ElementsByClass(doc, "ltb_center");

                int docNum = elements.Count();
                int index;

                for (int i = 0; i < docNum / 11; i++)
                {
                    string[] rows = new string[5];
                    IHTMLElement title = titles.ElementAt(i);

                    int titleLen = 30;

                    if (title.innerText.Count() > titleLen)
                    {
                        rows[1] += title.innerText.Substring(0, titleLen);
                        rows[1] += "\r\n";
                        rows[1] += title.innerText.Substring(titleLen);
                    }
                    else
                    {
                        rows[1] = title.innerText;
                    }

                    if (rows[1] == board4[0].rows[1 + diffCount])
                    {
                        return diffCount;
                    }
                    else
                    {
                        diffCount++;
                    }

                    rows[2] = elements.ElementAt(i * 11 + 5).innerText;
                    rows[3] = elements.ElementAt(i * 11 + 7).innerText;
                    rows[4] = elements.ElementAt(i * 11 + 3).innerText;

                    index = (pageNum - 1) * 10 + i;

                    new_board4[index].rows = rows;
                    new_board4[index].boardName = rows[4];
                    new_board4[index].page = pageNum;
                    new_board4[index].boardId = title.innerHTML.Substring(title.innerHTML.IndexOf("boardid=")).Substring(8);
                    new_board4[index].bullId = title.innerHTML.Substring(title.innerHTML.IndexOf("bullid=")).Substring(7);
                }
            }

            return diffCount;
        }
示例#3
0
        private void setBoard(PortalBoard[] board, string boardId, int sPage, int ePage)
        {
            MainForm.gridView.Columns[4].HeaderText = "조회수";

            for (int i = 0; i < 10 * 10; i++)
            {
                board[i] = new PortalBoard();
            }

            for (int pageNum = sPage; pageNum <= ePage; pageNum++)
            {
                string url = "http://portal.unist.ac.kr/EP/web/collaboration/bbs/jsp/BB_BoardLst.jsp?boardid=" + boardId + "&nfirst=" + pageNum;
                if (!getResponse(url))
                    return;

                doc = (IHTMLDocument2)new HTMLDocument();
                doc.clear();
                doc.write(resResult);
                doc.close();

                IEnumerable<IHTMLElement> titles = ElementsByClass(doc, "ltb_left");
                IEnumerable<IHTMLElement> elements = ElementsByClass(doc, "ltb_center");

                int docNum = elements.Count();
                int index;

                for (int i = 0; i < docNum / BOARDTAGNUM; i++)
                {
                    string[] rows = new string[5];
                    IHTMLElement title = titles.ElementAt(i);

                    rows[0] = "";
                    rows[1] = title.innerText;
                    rows[2] = elements.ElementAt(i * BOARDTAGNUM + 5).innerText;
                    rows[3] = elements.ElementAt(i * BOARDTAGNUM + 7).innerText;
                    rows[4] = elements.ElementAt(i * BOARDTAGNUM + 9).innerText;

                    index = (pageNum - 1) * 10 + i;

                    // new 체크
                    if (((IHTMLElement2)title).getElementsByTagName("img").length > 0)
                    {
                        board[index].newPost = true;
                        rows[0] = "new";
                    }

                    // 공지 체크
                    if (((IHTMLElement2)elements.ElementAt(i * BOARDTAGNUM + 1)).getElementsByTagName("img").length > 0)
                    {
                        board[index].anouncement = true;
                        rows[0] = "공지";
                    }

                    board[index].rows = rows;
                    //board[index].title = rows[1];
                    //board[index].writer = rows[2];
                    //board[index].date = rows[3];
                    //board[index].viewCount = Convert.ToInt32(rows[4]);
                    board[index].page = pageNum;
                    board[index].boardId = boardId;

                    // javascript:clickBulletin("BB201302011329070365135","BB201302011329070365135","BB201302011329070365135","0","N");
                    string javaUrl = title.innerHTML.Substring(title.innerHTML.IndexOf("javascript:"));
                    board[index].bullId = javaUrl.Split('\"')[1];

                    IHTMLElement font = (IHTMLElement)((IHTMLElement2)title).getElementsByTagName("font").item(0, 0);

                    if (font.getAttribute("color") != null)
                    {
                        board[index].color = ConvertColor_PhotoShopStyle_toRGB((string)font.getAttribute("color"));
                    }

                    if (title.outerHTML.IndexOf("FONT-WEIGHT: bold") != -1)
                    {
                        board[index].bold = true;
                    }
                }
            }
        }
示例#4
0
        /**********************************************************
         *
         *  포탈 검색, EUC-KR 인코딩
         *
         **********************************************************/
        private void searchBoard(PortalBoard[] board, string boardId, int sPage, int ePage, string query)
        {
            // http://portal.unist.ac.kr/EP/web/collaboration/bbs/jsp/BB_BoardLst.jsp?searchcondition=BULLTITLE&searchname=%B0%F8%C1%F6&boardid=B200902281833482321051&nfirst=1
            MainForm.gridView.Columns[4].HeaderText = "조회수";

            for (int i = 0; i < 10 * 10; i++)
            {
                board[i] = new PortalBoard();
            }

            for (int pageNum = sPage; pageNum <= ePage; pageNum++)
            {
                byte[] b = System.Text.Encoding.GetEncoding(51949).GetBytes(query);
                string result = "";

                foreach (byte ch in b)
                {
                    result += ("%" + string.Format("{0:x2} ", ch)); // 2자리의 16진수로 출력, [참고] 링크 읽어볼 것
                }

                string url = "http://portal.unist.ac.kr/EP/web/collaboration/bbs/jsp/BB_BoardLst.jsp?boardid=" + boardId + "&nfirst=" + pageNum
                    + "&searchcondition=BULLTITLE&searchname=" + result.Replace(" ","");
                if (!getResponse(url))
                    return;

                doc = (IHTMLDocument2)new HTMLDocument();
                doc.clear();
                doc.write(resResult);
                doc.close();

                IEnumerable<IHTMLElement> titles = ElementsByClass(doc, "ltb_left");
                IEnumerable<IHTMLElement> elements = ElementsByClass(doc, "ltb_center");

                int docNum = elements.Count();
                int index;

                if (docNum == 0)
                    return;

                for (int i = 0; i < docNum / BOARDTAGNUM; i++)
                {
                    string[] rows = new string[5];
                    IHTMLElement title = titles.ElementAt(i);

                    rows[0] = "";
                    rows[1] = title.innerText;
                    rows[2] = elements.ElementAt(i * BOARDTAGNUM + 5).innerText;
                    rows[3] = elements.ElementAt(i * BOARDTAGNUM + 7).innerText;
                    rows[4] = elements.ElementAt(i * BOARDTAGNUM + 9).innerText;

                    index = (pageNum - 1) * 10 + i;

                    // new 체크
                    if (((IHTMLElement2)title).getElementsByTagName("img").length > 0)
                    {
                        board[index].newPost = true;
                        rows[0] = "new";
                    }

                    // 공지 체크
                    if (((IHTMLElement2)elements.ElementAt(i * BOARDTAGNUM + 1)).getElementsByTagName("img").length > 0)
                    {
                        board[index].anouncement = true;
                        rows[0] = "공지";
                    }

                    board[index].rows = rows;
                    //board[index].title = rows[1];
                    //board[index].writer = rows[2];
                    //board[index].date = rows[3];
                    //board[index].viewCount = Convert.ToInt32(rows[4]);
                    board[index].page = pageNum;
                    board[index].boardId = boardId;

                    // javascript:clickBulletin("BB201302011329070365135","BB201302011329070365135","BB201302011329070365135","0","N");
                    string javaUrl = title.innerHTML.Substring(title.innerHTML.IndexOf("javascript:"));
                    board[index].bullId = javaUrl.Split('\"')[1];

                    IHTMLElement font = (IHTMLElement)((IHTMLElement2)title).getElementsByTagName("font").item(0, 0);

                    if (font.getAttribute("color") != null)
                    {
                        board[index].color = ConvertColor_PhotoShopStyle_toRGB((string)font.getAttribute("color"));
                    }

                    if (title.outerHTML.IndexOf("FONT-WEIGHT: bold") != -1)
                    {
                        board[index].bold = true;
                    }
                }
            }
        }