//Add tab
        protected void btn_addNewTab_Click(object sender, EventArgs e)
        {
            string newTabName = tb_newTabNew.Text.Trim();
            int    result     = MyProxy.getProxy().AddTab(newTabName);

            switch (result)
            {
            case 0:
            {
                lb_addTabResult.ForeColor = System.Drawing.Color.Green;
                lb_addTabResult.Text      = "Done!";
                RestoreTreeViewState();
                LoadUserContent();
                break;
            }

            case 1:
            {
                lb_addTabResult.ForeColor = System.Drawing.Color.Orange;
                lb_addTabResult.Text      = "Existed!";
                break;
            }

            case 2:
            {
                lb_addTabResult.ForeColor = System.Drawing.Color.Red;
                lb_addTabResult.Text      = "Fail!";
                break;
            }
            }
        }
        //delete rss item
        protected void lbtn_deleteRssItem_Click(object sender, EventArgs e)
        {
            if (currentRssItem == null)
            {
                return;
            }
            int tabParentID = int.Parse(currentRssItem.Parent.Value);
            int rssIdToDel  = int.Parse(currentRssItem.Value);

            if (MyProxy.getProxy().RemoveRSSItem(rssIdToDel))
            {
                RestoreTreeViewState();
                LoadUserContent();
                TreeNode tabParent = GetTreeNodeOfCurrentTab(currentTabID);
                if (tabParent.ChildNodes.Count > 0)
                {
                    int    newID     = int.Parse(tabParent.ChildNodes[0].Value);
                    string newTarget = tabParent.ChildNodes[0].Text;
                    LoadRssContent(newID, newTarget, tabParent.ChildNodes[0]);
                }
                else
                {
                    RestoreTreeViewState();
                    LoadUserContent();
                    LoadTabContent(tabParent.Text);
                }
            }
            else
            {
                lb_deleteResult.ForeColor = System.Drawing.Color.Red;
                lb_deleteResult.Text      = "Different Owner!";
            }
        }
        //Share tab
        protected void btn_ShareTab_Click(object sender, EventArgs e)
        {
            string userName = tb_UserNameToShare.Text.Trim();

            if (userName == "")
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "This user-name is empty";
                return;
            }
            int result = MyProxy.getProxy().ShareTab(currentTabID, userName);

            switch (result)
            {
            case 0:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Green;
                lb_ShareResult.Text      = "Done!";
                break;
            }

            case 1:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "Different owner!";
                break;
            }

            case 2:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "This tab doesn't exist!";
                break;
            }

            case 3:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "Doesn't exist!";
                break;
            }

            case 4:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "Can't share yourseft!";
                break;
            }

            case 5:
            {
                lb_ShareResult.ForeColor = System.Drawing.Color.Red;
                lb_ShareResult.Text      = "Fail!";
                break;
            }
            }
        }
 private void LoadTabContent(TabDTO tabparent, TreeNode tnodeparent)
 {
     RSSItemDTO[] listOfRssItem = MyProxy.getProxy().GetAllRSSItems(tabparent.Id);
     foreach (RSSItemDTO item in listOfRssItem)
     {
         TreeNode tnode = new TreeNode(item.Name, item.Id.ToString(), "Content/image/RssIcon.png");
         tnode.ToolTip = item.Description;
         tnodeparent.ChildNodes.Add(tnode);
     }
 }
Exemple #5
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            string userName = tb_UserName.Text.Trim();
            string passWord = tb_Password.Text.Trim();

            if (MyProxy.getProxy().Login(userName, passWord))
            {
                Session["UserName"] = userName;
                Response.Redirect("MainPage.aspx");
            }
        }
        private void LoadUserContent()
        {
            TabDTO[] listOfTab       = MyProxy.getProxy().GetAllTabs();
            TabDTO[] listOfSharedTab = MyProxy.getProxy().GetAllSharedTabs();

            tv_Content.Nodes.Clear();
            foreach (TabDTO tab in listOfTab)
            {
                TreeNode tnode = new TreeNode(tab.Name, tab.Id.ToString(), "Content/image/Container.png");
                if (tv_Content_ExpandState.ContainsKey(tab.Id.ToString()))
                {
                    tnode.Expanded = tv_Content_ExpandState[tab.Id.ToString()];
                }
                else
                {
                    tnode.Expanded = false;
                }

                LoadTabContent(tab, tnode);
                tv_Content.Nodes.Add(tnode);

                if (currentTabID == 0)
                {
                    currentTabID = tab.Id;
                    LoadTabContent(tab.Name);
                    currentRssItem = null;
                }
            }

            foreach (TabDTO tab in listOfSharedTab)
            {
                string   tabNameToDisPlay = tab.Name + " (from: " + tab.OwnerUsername + " )";
                TreeNode tnode            = new TreeNode(tabNameToDisPlay, tab.Id.ToString(), "Content/image/ShareContainer.png");
                if (tv_Content_ExpandState.ContainsKey(tab.Id.ToString()))
                {
                    tnode.Expanded = tv_Content_ExpandState[tab.Id.ToString()];
                }
                else
                {
                    tnode.Expanded = false;
                }

                LoadTabContent(tab, tnode);
                tv_Content.Nodes.Add(tnode);

                if (currentTabID == 0)
                {
                    currentTabID = tab.Id;
                    LoadTabContent(tab.Name);
                    currentRssItem = null;
                }
            }
        }
        //Rename
        protected void btn_RenameTab_Click(object sender, EventArgs e)
        {
            string newTabName = tb_NewTabName.Text.Trim();

            if (newTabName == "")
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Red;
                lb_RenameResult.Text      = "Tab-name is empty!";
                return;
            }
            int result = MyProxy.getProxy().RenameTab(currentTabID, newTabName);

            switch (result)
            {
            case 0:
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Green;
                lb_RenameResult.Text      = "Done!";
                RestoreTreeViewState();
                LoadUserContent();
                break;
            }

            case 1:
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Red;
                lb_RenameResult.Text      = "Different owner!";
                break;
            }

            case 2:
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Red;
                lb_RenameResult.Text      = "Doesn't exist!";
                break;
            }

            case 3:
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Red;
                lb_RenameResult.Text      = "Duplicate name!";
                break;
            }

            case 4:
            {
                lb_RenameResult.ForeColor = System.Drawing.Color.Red;
                lb_RenameResult.Text      = "Fail!";
                break;
            }
            }
        }
        //Delete tab
        protected void lbtn_deleteTab_Click(object sender, EventArgs e)
        {
            int result = MyProxy.getProxy().RemoveTab(currentTabID);

            switch (result)
            {
            case 0:
            {
                currentTabID   = 0;
                currentRssItem = null;
                RestoreTreeViewState();
                LoadUserContent();
                if (currentTabID == 0)
                {
                    dtl_RssContent.DataSource = null;
                    dtl_RssContent.DataBind();

                    dtl_tabContent.DataSource = null;
                    dtl_tabContent.DataBind();

                    lbtn_deleteRssItem.Visible = false;
                    lbtn_deleteTab.Visible     = false;
                    lbtn_shareTab.Visible      = false;
                    lb_currentPath.Text        = "";
                }
                break;
            }

            case 1:
            {
                lb_deleteResult.ForeColor = System.Drawing.Color.Red;
                lb_deleteResult.Text      = "Different Owner!";
                break;
            }

            case 2:
            {
                lb_deleteResult.ForeColor = System.Drawing.Color.Red;
                lb_deleteResult.Text      = "Not exist!";
                break;
            }

            case 3:
            {
                lb_deleteResult.ForeColor = System.Drawing.Color.Red;
                lb_deleteResult.Text      = "Fail!";
                break;
            }
            }
        }
        protected void btn_CreateAccount_Click(object sender, EventArgs e)
        {
            string username = tb_UserName.Text;
            string password = tb_PassWord.Text;

            if (!MyProxy.getProxy().CheckValidUsername(username))
            {
                lb_UNConflictStateMent.Text = "This user-name was already used!";
            }
            else
            {
                if (MyProxy.getProxy().Register(username, password))
                {
                    Response.Redirect("RegisterResult.aspx");
                }
            }
        }
        //Add một link rss mới vào 1 tab
        protected void btn_addNewRssLink_Click(object sender, EventArgs e)
        {
            string url    = tb_newRssLink.Text.Trim();
            int    result = MyProxy.getProxy().AddRSSItem(currentTabID, url);

            switch (result)
            {
            case 0:
            {
                lb_addResult.ForeColor = System.Drawing.Color.Green;
                lb_addResult.Text      = "  Done!";
                RestoreTreeViewState();
                LoadUserContent();
                break;
            }

            case 1:
            {
                lb_addResult.ForeColor = System.Drawing.Color.Orange;
                lb_addResult.Text      = "  Has been existed in your tab!";
                break;
            }

            case 2:
            {
                lb_addResult.ForeColor = System.Drawing.Color.Red;
                lb_addResult.Text      = "  Incorrect link!";
                break;
            }

            case 3:
            {
                lb_addResult.ForeColor = System.Drawing.Color.Red;
                lb_addResult.Text      = "  Different Onwer!";
                break;
            }

            case 4:
            {
                lb_addResult.ForeColor = System.Drawing.Color.Red;
                lb_addResult.Text      = "  Fail!";
                break;
            }
            }
        }
        //Load nội dung tab và 3 rss item đầu tiên khi click vào 1 container
        private void LoadTabContent(string target)
        {
            lbtn_deleteRssItem.Visible = false;
            lbtn_deleteTab.Visible     = true;
            lbtn_shareTab.Visible      = true;
            lbtn_Rename.Visible        = true;

            lb_currentPath.Text = target;

            dtl_RssContent.DataSource = null;
            dtl_RssContent.DataBind();

            List <RSSItemDTO> listOfItem = MyProxy.getProxy().GetAllRSSItems(currentTabID).ToList();

            dtl_tabContent.DataSource = listOfItem;
            dtl_tabContent.DataBind();
            int count = 0;

            foreach (RSSItemDTO item in listOfItem)
            {
                string      xmlStr = MyProxy.getProxy().GetRSSResult(item.Id, 3);
                XmlDocument doc    = new XmlDocument();
                doc.LoadXml(xmlStr);

                XmlNode channelNode = doc.SelectSingleNode("//channel");
                if (channelNode != null)
                {
                    XmlNode titleNode = channelNode.SelectSingleNode("./title");
                    XmlNode desNode   = channelNode.SelectSingleNode("./link");

                    if (titleNode != null && desNode != null)
                    {
                        LinkButton lbtn = (LinkButton)dtl_tabContent.Items[count].FindControl("lbtn_rss_name");
                        lbtn.Text    = titleNode.InnerText;
                        lbtn.ToolTip = desNode.InnerText;

                        lbtn.CommandName     = titleNode.InnerText;
                        lbtn.CommandArgument = item.Id.ToString();
                    }
                }

                XmlNodeList listOfRSSItem = doc.SelectNodes("//item");
                if (listOfRSSItem.Count == 3)
                {
                    XmlNode titleNode_1 = listOfRSSItem[0].SelectSingleNode("./title");
                    XmlNode linkNode_1  = listOfRSSItem[0].SelectSingleNode("./link");

                    if (titleNode_1 != null && linkNode_1 != null)
                    {
                        HyperLink hpl1 = (HyperLink)dtl_tabContent.Items[count].FindControl("hpl_rss_1");
                        hpl1.Text        = titleNode_1.InnerText;
                        hpl1.NavigateUrl = linkNode_1.InnerText;
                    }

                    XmlNode titleNode_2 = listOfRSSItem[1].SelectSingleNode("./title");
                    XmlNode linkNode_2  = listOfRSSItem[1].SelectSingleNode("./link");

                    if (titleNode_2 != null && linkNode_2 != null)
                    {
                        HyperLink hpl2 = (HyperLink)dtl_tabContent.Items[count].FindControl("hpl_rss_2");
                        hpl2.Text        = titleNode_2.InnerText;
                        hpl2.NavigateUrl = linkNode_2.InnerText;
                    }

                    XmlNode titleNode_3 = listOfRSSItem[2].SelectSingleNode("./title");
                    XmlNode linkNode_3  = listOfRSSItem[2].SelectSingleNode("./link");

                    if (titleNode_3 != null && linkNode_3 != null)
                    {
                        HyperLink hpl3 = (HyperLink)dtl_tabContent.Items[count].FindControl("hpl_rss_3");
                        hpl3.Text        = titleNode_3.InnerText;
                        hpl3.NavigateUrl = linkNode_3.InnerText;
                    }
                }
                count++;
            }
        }
        //Add các content lên rss khi click vao 1 rss item
        private void LoadRssContent(int currentID, string target, TreeNode currentNode)
        {
            lbtn_deleteRssItem.Visible = true;
            lbtn_deleteTab.Visible     = false;
            lbtn_shareTab.Visible      = false;
            lbtn_Rename.Visible        = false;

            currentRssItem = currentNode;

            lb_currentPath.Text = target;

            dtl_tabContent.DataSource = null;
            dtl_tabContent.DataBind();

            string      xmlStr = MyProxy.getProxy().GetRSSResult(currentID, 15);
            XmlDocument doc    = new XmlDocument();

            doc.LoadXml(xmlStr);

            XmlNodeList listOfItem = doc.SelectNodes("//item");

            dtl_RssContent.DataSource = listOfItem;
            dtl_RssContent.DataBind();
            int m     = dtl_RssContent.Items.Count;
            int count = 0;

            foreach (XmlNode node in listOfItem)
            {
                XmlNode titleNode       = node.SelectSingleNode("./title");
                XmlNode linkNode        = node.SelectSingleNode("./link");
                XmlNode descriptionNode = node.SelectSingleNode("./description");
                XmlNode pubdateNode     = node.SelectSingleNode("./pubDate");
                if (pubdateNode == null)
                {
                    pubdateNode = node.SelectSingleNode("./pubdate");
                }

                if (titleNode != null && linkNode != null)
                {
                    HyperLink hpl = (HyperLink)dtl_RssContent.Items[count].FindControl("hl_title");
                    hpl.Text        = titleNode.InnerText;
                    hpl.NavigateUrl = linkNode.InnerText;
                    hpl.ToolTip     = linkNode.InnerText;
                }
                if (pubdateNode != null)
                {
                    Label lb = (Label)dtl_RssContent.Items[count].FindControl("lb_time");
                    try
                    {
                        DateTime postTime = DateTime.Parse(pubdateNode.InnerText);
                        lb.Text = postTime.ToLongDateString() + " - " + postTime.ToLongTimeString();
                    }
                    catch
                    {
                        lb.Text = pubdateNode.InnerText;
                    }
                }
                if (descriptionNode != null)
                {
                    Literal lt = (Literal)dtl_RssContent.Items[count].FindControl("lt_newsContent");
                    lt.Text = descriptionNode.InnerText;
                }
                count++;
            }
        }
Exemple #13
0
 protected void lbn_LogOut_Click(object sender, EventArgs e)
 {
     MyProxy.getProxy().Logout();
     Response.Redirect("Default.aspx");
 }