Esempio n. 1
0
 public void init()
 {
     WebClient client = newWebClient();
     client.QueryString.Add("include", "memberships");
     Stream stream = client.OpenRead(string.Format("{0}/users/current.xml", domain));
     XmlDocument xml = new XmlDocument();
     xml.Load(stream);
     XmlNode node = xml.SelectSingleNode("user");
     user = new User();
     user.id = node.SelectSingleNode("id").InnerText;
     user.firstname = node.SelectSingleNode("firstname").InnerText;
     user.lastname = node.SelectSingleNode("lastname").InnerText;
     user.mail = node.SelectSingleNode("mail").InnerText;
     user.created_on = node.SelectSingleNode("created_on").InnerText;
     user.last_login_on = node.SelectSingleNode("last_login_on").InnerText;
     XmlNodeList nodeList = node.SelectNodes("memberships/membership");
     foreach (XmlNode m_node in nodeList)
     {
         Membership membership = new Membership();
         membership.id = m_node.SelectSingleNode("id").InnerText;
         XmlNode project = m_node.SelectSingleNode("project");
         membership.project = new Item { id = project.Attributes["id"].Value, name = project.Attributes["name"].Value };
         XmlNode role = m_node.SelectSingleNode("roles").SelectSingleNode("role");
         membership.role = new Item { id = role.Attributes["id"].Value, name = role.Attributes["name"].Value };
         memberships.Add(membership);
     }
 }
Esempio n. 2
0
        private void mst_issues_Click(object sender, EventArgs e)
        {
            panel_clear();

            ComboBox cb_project = new ComboBox();
            cb_project.Width = 250;
            cb_project.Name = "cb_project";
            IList<Membership> memberships = (from m in service.memberships orderby m.role_name select m).ToList();
            Membership all_membership = new Membership();
            all_membership.project = new Item { name = "全部项目"};
            all_membership.role = new Item { name = "ALL" };
            memberships.Insert(0, all_membership);
            cb_project.DataSource = memberships;
            cb_project.DisplayMember = "role_project";
            cb_project.ValueMember = "project_id";
            cb_project.DropDownStyle = ComboBoxStyle.DropDownList;
            cb_project.SelectedValueChanged += load_issues;
            add_control("项目:", cb_project, false);

            ComboBox cb_type = new ComboBox();
            cb_type.Width = 250;
            cb_type.Name = "cb_type";
            cb_type.DataSource = new List<Item> { new Item { name = "指派给我", id = "1" },
            new Item { name = "我指派的", id = "2" },new Item { name = "全部", id = "3" }};
            cb_type.DisplayMember = "name";
            cb_type.ValueMember = "id";
            cb_type.DropDownStyle = ComboBoxStyle.DropDownList;
            cb_type.SelectedValueChanged += load_issues;
            add_control("类型:", cb_type, false);

            //-------------------------------------------------------

            ComboBox cb_issues = new ComboBox();
            cb_issues.TabIndex = 0;
            cb_issues.Width = 571;
            cb_issues.Name = "cb_issues";
            cb_issues.DropDownStyle = ComboBoxStyle.DropDownList;
            cb_issues.SelectedValueChanged += cb_issues_SelectedValueChanged;
            add_control("任务:", cb_issues, true);

            //-------------------------------------------------------
            ComboBox cb_status = new ComboBox();
            cb_status.Width = 250;
            cb_status.Name = "cb_status";
            cb_status.DataSource = new List<Item> { new Item { name = "全部"},
            new Item { name = "待分派", id = "1" },new Item { name = "已分派", id = "7" },
            new Item { name = "已接手", id = "8" },new Item { name = "已拒绝", id = "6" },
            new Item { name = "进行中", id = "2" },new Item { name = "已解决", id = "3" },
            new Item { name = "已关闭", id = "5" }};
            cb_status.DisplayMember = "name";
            cb_status.ValueMember = "id";
            cb_status.DropDownStyle = ComboBoxStyle.DropDownList;
            cb_status.SelectedValueChanged += load_issues;
            add_control("状态:", cb_status, false);

            /**ComboBox cb_tracker = new ComboBox();
            cb_tracker.Width = 250;
            cb_tracker.Name = "cb_tracker";
            cb_tracker.DataSource = new List<Item> { new Item { name = "全部"},
            new Item { name = "错误", id = "1" },new Item { name = "功能", id = "2" },
            new Item { name = "支持", id = "3" },new Item { name = "维护", id = "5" }};
            cb_tracker.DisplayMember = "name";
            cb_tracker.ValueMember = "id";
            cb_tracker.DropDownStyle = ComboBoxStyle.DropDownList;
            cb_tracker.SelectedValueChanged += load_issues;
            add_control("跟踪:", cb_tracker, false);*/

            add_item("项目:", "tb_project", true, true);
            ((TextBox)panel_context.Controls["tb_project"]).Width = 248;

            //---------------------------------------------------------------
            add_item("I  D:", "tb_id", true, false);
            add_item("作者:", "tb_author", true, false);
            add_item("指派:", "tb_assigned_to", true, true);
            //---------------------------------------------------------------
            add_item("跟踪:", "tb_tracker", true, false);
            add_item("状态:", "tb_status", true, false);
            add_item("优先:", "tb_priority", true, false);
            add_item("开始:", "tb_start_date", true, true);
            //---------------------------------------------------------------
            add_item("创建:", "tb_created_on", true, false);
            ((TextBox)panel_context.Controls["tb_created_on"]).Width = 248;
            add_item("更新:", "tb_updated_on", true, true);
            ((TextBox)panel_context.Controls["tb_updated_on"]).Width = 248;
            //---------------------------------------------------------------

            TextBox tb_description = new TextBox();
            tb_description.Name = "tb_description";
            tb_description.ScrollBars = ScrollBars.Vertical;
            tb_description.Multiline = true;
            tb_description.ReadOnly = true;
            tb_description.Height = 88;
            tb_description.Text = "...";
            tb_description.Width = 570;
            add_control("描述:", tb_description, true);
            //---------------------------------------------------------------
            Button btn_new = new Button();
            btn_new.Name = "btn_new";
            btn_new.Text = "新建问题";
            btn_new.Click += btn_new_Click;
            add_control("",btn_new, false);

            Button btn_solve = new Button();
            btn_solve.Name = "btn_solve";
            btn_solve.Text = "标记为解决";
            btn_solve.Click += btn_solve_Click;
            add_control(btn_solve, false);

            Button btn_close = new Button();
            btn_close.Name = "btn_close";
            btn_close.Text = "标记为关闭";
            btn_close.Click += btn_close_Click;
            add_control(btn_close, false);

            load_issues(sender, e);
        }