예제 #1
0
        /// <summary>
        /// Binds the options.
        /// </summary>
        private void BindOptions()
        {
            List<ITUser> users = UserManager.GetUsersByProjectId(ProjectId, true);
            //Get Type
            DropIssueType.DataSource = IssueTypeManager.GetByProjectId(ProjectId);
            DropIssueType.DataBind();

            //Get Priority
            DropPriority.DataSource = PriorityManager.GetByProjectId(ProjectId);
            DropPriority.DataBind();

            //Get Resolutions
            DropResolution.DataSource = ResolutionManager.GetByProjectId(ProjectId);
            DropResolution.DataBind();

            //Get categories
            var categories = new CategoryTree();
            DropCategory.DataSource = categories.GetCategoryTreeByProjectId(ProjectId);
            DropCategory.DataBind();

            //Get milestones
            DropMilestone.DataSource = MilestoneManager.GetByProjectId(ProjectId);
            DropMilestone.DataBind();

            DropAffectedMilestone.DataSource = MilestoneManager.GetByProjectId(ProjectId);
            DropAffectedMilestone.DataBind();

            //Get Users
            DropAssignedTo.DataSource = users;
            DropAssignedTo.DataBind();

            DropOwned.DataSource = users;
            DropOwned.DataBind();         

            DropStatus.DataSource = StatusManager.GetByProjectId(ProjectId);
            DropStatus.DataBind();

            lblDateCreated.Text = DateTime.Now.ToString("f");
            lblLastModified.Text = DateTime.Now.ToString("f");

            if (!User.Identity.IsAuthenticated) return;

            lblReporter.Text = Security.GetDisplayName();
            lblLastUpdateUser.Text = Security.GetDisplayName();
        }
예제 #2
0
        /// <summary>
        /// Binds the options.
        /// </summary>
        private void BindOptions()
        {
            List<ITUser> users = UserManager.GetUsersByProjectId(ProjectId, true);
           
            //Get Type
            DropIssueType.DataSource = IssueTypeManager.GetByProjectId(ProjectId);
            DropIssueType.DataBind();

            //Get Priority
            DropPriority.DataSource = PriorityManager.GetByProjectId(ProjectId);
            DropPriority.DataBind();

            //Get Resolutions
            DropResolution.DataSource = ResolutionManager.GetByProjectId(ProjectId);
            DropResolution.DataBind();

            //Get categories
            var categories = new CategoryTree();
            DropCategory.DataSource = categories.GetCategoryTreeByProjectId(ProjectId);
            DropCategory.DataBind();

            //Get milestones
            DropMilestone.DataSource = MilestoneManager.GetByProjectId(ProjectId, false);
            DropMilestone.DataBind();

            DropAffectedMilestone.DataSource = MilestoneManager.GetByProjectId(ProjectId);
            DropAffectedMilestone.DataBind();

            //Get Users
            DropAssignedTo.DataSource = users;
            DropAssignedTo.DataBind();

            DropOwned.DataSource = users;
            DropOwned.DataBind();
            DropOwned.SelectedValue = User.Identity.Name;

            DropStatus.DataSource = StatusManager.GetByProjectId(ProjectId);
            DropStatus.DataBind();
        }
예제 #3
0
        /// <summary>
        /// When the user changes the selected field type, show the corresponding list
        /// of possible values.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void dropFieldSelectedIndexChanged(Object s, EventArgs e)
        {
            dropValue.Items.Clear();
            switch (dropField.SelectedValue)
            {
                case "IssueId":
                    dropValue.Visible = false;
                    txtValue.Visible = true;
                    DateValue.Visible = false;
                    break;
                case "IssueTitle":
                    dropValue.Visible = false;
                    txtValue.Visible = true;
                    DateValue.Visible = false;
                    break;
                case "IssueDescription":
                    dropValue.Visible = false;
                    txtValue.Visible = true;
                    DateValue.Visible = false;
                    break;
                case "IssueVotes":
                    dropValue.Visible = false;
                    txtValue.Visible = true;
                    DateValue.Visible = false;
                    break;
                case "IssuePriorityId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = PriorityManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueTypeId":
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = IssueTypeManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueMilestoneId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = MilestoneManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueAffectedMilestoneId":
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = MilestoneManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueResolutionId":
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = ResolutionManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueCategoryId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    CategoryTree objCats = new CategoryTree();
                    dropValue.DataSource = objCats.GetCategoryTreeByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueStatusId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = StatusManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueAssignedUserId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "IssueOwnerUserId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueCreatorUserId" :
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    DateValue.Visible = false;
                    break;
                case "DateCreated":
                    dropValue.Visible = false;
                    txtValue.Visible = false;
                    DateValue.Visible = true;
                    break;
                case "LastUpdate":
                    dropValue.Visible = false;
                    txtValue.Visible = false;
                    DateValue.Visible = true;
                    break;
                case "IssueDueDate":
                    dropValue.Visible = false;
                    txtValue.Visible = false;
                    DateValue.Visible = true;
                    break;
                case "CustomFieldName":
                    dropValue.Visible = false;
                    txtValue.Visible = true;  //show the text value field. Not needed.
                    if (CustomFieldManager.GetByProjectId(ProjectId).Count > 0 )
                    {
                        dropField.DataSource = CustomFieldManager.GetByProjectId(ProjectId);
                        dropField.DataTextField = "Name";
                        dropField.DataValueField = "Name";
                        dropField.DataBind();// bind to the new datasource.
                        dropField.Items.Add("--Reset Fields--");
                        dropField.Items.Insert(0, new ListItem("-- Select Custom Field --","0"));
                        CustomFieldQuery = true;
                    }
                    break;
                default :
                    if (dropField.SelectedItem.Text.Equals("-- Select Custom Field --".ToString()))
                        return;
                    // The user decides to reset the fields
                    if (dropField.SelectedItem.Text.Equals("--Reset Fields--".ToString()))
                    {
                        dropField.DataSource = null;
                        dropField.DataSource = RequiredFieldManager.GetRequiredFields();
                        dropField.DataTextField = "Name";
                        dropField.DataValueField = "Value";
                        dropField.DataBind();
                        CustomFieldQuery = false;
                    }
                    //RW Once the list is populated with any varying type of name,
                    //we just default to this case, because we know it is not a standard field.
                    else
                    {
                        //check the type of this custom field and load the appropriate values.
                        CustomField cf = CustomFieldManager.GetByProjectId(ProjectId).Find(delegate(CustomField  c) { return c.Name == dropField.SelectedValue; });
                        if (cf == null)
                            return;

                        if (cf.FieldType == Common.CustomFieldType.DropDownList)
                        {
                            txtValue.Visible = false;
                            dropValue.Visible = true;
                            dropValue.DataSource = CustomFieldSelectionManager.GetByCustomFieldId(cf.Id);
                            dropValue.DataTextField = "Name";
                            dropValue.DataValueField = "Value";
                        }
                        else if (cf.FieldType == Common.CustomFieldType.Date)
                        {
                            dropValue.Visible = false;
                            txtValue.Visible = false;
                            DateValue.Visible = true;
                        }
                        else
                        {
                            dropValue.Visible = false;
                            txtValue.Visible = true;
                            DateValue.Visible = false;
                        }
                    }
                    break;
            }
            try{
                dropValue.DataBind();
            }catch{}
        }
 /// <summary>
 /// Inits this instance.
 /// </summary>
 public void Initialize()
 {
     var categories = new CategoryTree();
     DropCategory.DataSource = categories.GetCategoryTreeByProjectId(ProjectId);
     DropCategory.DataBind();
 }
예제 #5
0
        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        public new void DataBind()
        {
            //Private issue check
            DataSource = IssueManager.StripPrivateIssuesForRequestor(DataSource, Security.GetUserName()).ToList();

            if (DataSource.Count > 0)
            {
                gvIssues.Visible = true;
                pager.Visible = true;
                ScrollPanel.Visible = true;
                OptionsContainerPanel.Visible = true;

                var pId = Request.QueryString.Get("pid", -1);

                //get custom fields for project
                if (pId > Globals.NEW_ID)
                {
                    var customFields = CustomFieldManager.GetByProjectId(pId);

                    var nrColumns = FIXED_COLUMNS;
                    //checks if its initial load to add custom controls and checkboxes
                    if (gvIssues.Columns.Count <= nrColumns + 1)
                    {
                        var firstIssue = DataSource[0];

                        //if there is custom fields add them
                        if (firstIssue.IssueCustomFields.Count > 0)
                        {
                            foreach (var value in firstIssue.IssueCustomFields)
                            {
                                //increments nr of columns
                                nrColumns++;

                                //create checkbox item
                                var lstValue = new ListItem(value.FieldName, nrColumns.ToString());

                                //find custom controls that has been checked and check them
                                var selected = Array.IndexOf(_arrIssueColumns, nrColumns.ToString()) >= 0;
                                if (selected)
                                    lstValue.Selected = true;

                                //add item to checkbox list
                                lstIssueColumns.Items.Add(lstValue);

                                //create column for custom control
                                var tf = new TemplateField { HeaderText = value.FieldName, SortExpression = value.DatabaseFieldName.Replace(" ", "[]") };
                                tf.HeaderStyle.Wrap = false;
                                gvIssues.Columns.Add(tf);
                            }
                        }
                    }
                }

                DisplayColumns();
                SelectColumnsPanel.Visible = true;
                lblResults.Visible = false;

                if (ShowProjectColumn)
                {
                    gvIssues.Columns[0].Visible = false;
                    LeftButtonContainerPanel.Visible = false;
                }
                else
                {
                    gvIssues.Columns[4].Visible = false;
                    lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));

                    var projectId = _dataSource[0].ProjectId;

                    //hide votes column if issue voting is disabled
                    if (!ProjectManager.GetById(projectId).AllowIssueVoting)
                    {
                        gvIssues.Columns[4].Visible = false;
                        lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));
                    }

                    if (Page.User.Identity.IsAuthenticated && UserManager.HasPermission(projectId, Common.Permission.EditIssue.ToString()))
                    {
                        LeftButtonContainerPanel.Visible = true;

                        // performance enhancement
                        // WRH 2012-04-06
                        // only load these if the user has permission to do so
                        var categories = new CategoryTree();
                        dropCategory.DataSource = categories.GetCategoryTreeByProjectId(projectId);
                        dropCategory.DataBind();
                        dropMilestone.DataSource = MilestoneManager.GetByProjectId(projectId);
                        dropMilestone.DataBind();
                        dropAffectedMilestone.DataSource = dropMilestone.DataSource;
                        dropAffectedMilestone.DataBind();
                        dropOwner.DataSource = UserManager.GetUsersByProjectId(projectId);
                        dropOwner.DataBind();
                        dropPriority.DataSource = PriorityManager.GetByProjectId(projectId);
                        dropPriority.DataBind();
                        dropStatus.DataSource = StatusManager.GetByProjectId(projectId);
                        dropStatus.DataBind();
                        dropType.DataSource = IssueTypeManager.GetByProjectId(projectId);
                        dropType.DataBind();
                        dropAssigned.DataSource = UserManager.GetUsersByProjectId(projectId);
                        dropAssigned.DataBind();
                        dropResolution.DataSource = ResolutionManager.GetByProjectId(projectId);
                        dropResolution.DataBind();
                        chkDueDateReset.Checked = false;
                    }
                    else
                    {
                        //hide selection column for unauthenticated users 
                        gvIssues.Columns[0].Visible = false;
                        LeftButtonContainerPanel.Visible = false;
                    }
                }

                foreach (var item in _arrIssueColumns.Select(colIndex => lstIssueColumns.Items.FindByValue(colIndex)).Where(item => item != null))
                {
                    item.Selected = true;
                }

                gvIssues.DataSource = DataSource;
                gvIssues.DataBind();
            }
            else
            {
                ScrollPanel.Visible = false;
                OptionsContainerPanel.Visible = false;
                lblResults.Visible = true;
                gvIssues.Visible = false;
                pager.Visible = false;
            }

        }
예제 #6
0
        /// <summary>
        /// Creates an RSS news feed for Issues By category
        /// </summary>
        /// <param name="feed">The feed.</param>
        private void CategoryFeed(ref SyndicationFeed feed)
        {
            var objComps = new CategoryTree();
            List<Category> al = objComps.GetCategoryTreeByProjectId(_projectId);

            var feedItems = new List<SyndicationItem>();
            Project p = ProjectManager.GetById(_projectId);

            foreach (Category c in al)
            {
                var item = new SyndicationItem();

                item.Title = SyndicationContent.CreatePlaintextContent(c.Name);
                item.Links.Add(
                    SyndicationLink.CreateAlternateLink(
                        new Uri(
                            GetFullyQualifiedUrl(string.Format("~/Issues/IssueList.aspx?pid={0}&c={1}", _projectId,
                                                               c.Id)))));
                item.Summary =
                    SyndicationContent.CreatePlaintextContent(
                        string.Format(GetLocalResourceObject("OpenIssues").ToString(), IssueManager.GetCountByProjectAndCategoryId(_projectId, c.Id)));
                item.PublishDate = DateTime.Now;
                // Add the item to the feed
                feedItems.Add(item);
            }
            feed.Title =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("IssuesByCategoryTitle").ToString(), p.Name));
            feed.Description =
                SyndicationContent.CreatePlaintextContent(
                    string.Format(GetLocalResourceObject("IssuesByCategoryDescription").ToString(), p.Name));
            feed.Items = feedItems;
        }
예제 #7
0
        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        public override void DataBind()
        {
            if(this.DataSource.Count > 0)
            {
                if (!string.IsNullOrEmpty(gvIssues.SortField))
                {
                    //_DataSource.Sort(gvIssues.SortField);
                    _DataSource.Sort(new IssueComparer(SortField, SortAscending));
                   //_DataSource.Sort(new ObjectComparer<Issue>(gvIssues.SortField, true));
                }

                gvIssues.Visible = true;
                pager.Visible = true;
                DisplayColumns();

                SelectColumnsPanel.Visible = true;

                //Table tb = (Table)gvIssues.Controls[0];
                //TableRow pagerRow = tb.Rows[tb.Rows.Count - 1]; //last row in the table is for bottom pager
                //pagerRow.Cells[0].Attributes.Remove("colspan");
                //pagerRow.Cells[0].Attributes.Add("colspan",_arrIssueColumns.Length.ToString() + 4);

                lblResults.Visible=false;

                if (ShowProjectColumn)
                {
                    gvIssues.Columns[0].Visible = false;
                    LeftButtonContainerPanel.Visible = false;
                }
                else
                {
                    gvIssues.Columns[4].Visible = false;
                    lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));

                    int projectId = ((Issue)_DataSource[0]).ProjectId;

                      //foreach(CustomField cf in CustomField.GetByProjectId(projectId))
                      //{

                      //    TemplateField ckhColumn = new TemplateField();

                      //    ckhColumn.HeaderTemplate = new GridViewTemplate(DataControlRowType.Header, cf.Name);

                      //    ckhColumn.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, cf.Name);
                      //    ckhColumn.Visible = true;
                      //    gvIssues.Columns.Add(ckhColumn);

                      //}

                    //hide votes column if issue voting is disabled
                    if (!ProjectManager.GetById(projectId).AllowIssueVoting)
                    {
                        gvIssues.Columns[4].Visible = false;
                        lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));
                    }

                    if ((!Page.User.Identity.IsAuthenticated) || (UserManager.HasPermission(projectId, Globals.Permission.EditIssue.ToString()) == false) ||
                        (UserManager.IsInRole(projectId, Globals.DefaultRoles[0]) == false))
                    {
                        //hide selection column for unauthenticated users
                        gvIssues.Columns[0].Visible = false;
                        LeftButtonContainerPanel.Visible = false;
                    }
                    else
                        LeftButtonContainerPanel.Visible = true;

                    CategoryTree categories = new CategoryTree();
                    dropCategory.DataSource = categories.GetCategoryTreeByProjectId(projectId);
                    dropCategory.DataBind();
                    dropMilestone.DataSource = MilestoneManager.GetByProjectId(projectId);
                    dropMilestone.DataBind();
                    dropAffectedMilestone.DataSource = MilestoneManager.GetByProjectId(projectId);
                    dropAffectedMilestone.DataBind();
                    dropOwner.DataSource = UserManager.GetUsersByProjectId(projectId);
                    dropOwner.DataBind();
                    dropPriority.DataSource = PriorityManager.GetByProjectId(projectId);
                    dropPriority.DataBind();
                    dropStatus.DataSource = StatusManager.GetByProjectId(projectId);
                    dropStatus.DataBind();
                    dropType.DataSource = IssueTypeManager.GetByProjectId(projectId);
                    dropType.DataBind();
                    dropAssigned.DataSource = UserManager.GetUsersByProjectId(projectId);
                    dropAssigned.DataBind();
                    dropResolution.DataSource = ResolutionManager.GetByProjectId(projectId);
                    dropResolution.DataBind();
                }

                foreach (string colIndex in _arrIssueColumns)
                {
                    ListItem item = lstIssueColumns.Items.FindByValue(colIndex);
                    if (item != null)
                        item.Selected = true;
                }

                gvIssues.DataSource = this.DataSource;
                gvIssues.DataBind();

            }
            else
            {
                OptionsContainerPanel.Visible = false;
                lblResults.Visible = true;
                gvIssues.Visible = false;
                pager.Visible = false;
            }
        }
예제 #8
0
        /// <summary>
        /// When the user changes the selected field type, show the corresponding list
        /// of possible values.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void dropFieldSelectedIndexChanged(Object s, EventArgs e)
        {
            dropValue.Items.Clear();

            dropValue.Visible = false;
            txtValue.Visible = false;
            DateValue.Visible = false;

            switch (dropField.SelectedValue)
            {
                case "IssueId":
                case "IssueTitle":
                case "IssueDescription":
                case "IssueVotes":
                case "IssueProgress":
                case "IssueEstimation":
                case "TimeLogged":
                    txtValue.Visible = true;
                    break;
                case "IssuePriorityId":
                    dropValue.Visible = true;

                    dropValue.DataSource = PriorityManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueTypeId":
                    dropValue.Visible = true;

                    dropValue.DataSource = IssueTypeManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueMilestoneId":
                    dropValue.Visible = true;

                    dropValue.DataSource = MilestoneManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueAffectedMilestoneId":
                    dropValue.Visible = true;

                    dropValue.DataSource = MilestoneManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueResolutionId":
                    dropValue.Visible = true;

                    dropValue.DataSource = ResolutionManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueCategoryId":
                    dropValue.Visible = true;

                    var objCats = new CategoryTree();
                    dropValue.DataSource = objCats.GetCategoryTreeByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";

                    break;
                case "IssueStatusId":
                    dropValue.Visible = true;

                    dropValue.DataSource = StatusManager.GetByProjectId(ProjectId);
                    dropValue.DataTextField = "Name";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueAssignedUserId":
                    dropValue.Visible = true;

                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueOwnerUserId":
                    dropValue.Visible = true;
                    txtValue.Visible = false;
                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    break;
                case "IssueCreatorUserId":
                    dropValue.Visible = true;

                    dropValue.DataSource = UserManager.GetUsersByProjectId(ProjectId);
                    dropValue.DataTextField = "DisplayName";
                    dropValue.DataValueField = "Id";
                    break;
                case "DateCreatedAsDate":
                case "LastUpdateAsDate":
                case "IssueDueDate":
                    DateValue.Visible = true;
                    break;
                case "CustomFieldName":

                    dropValue.Visible = false;
                    txtValue.Visible = true;  //show the text value field. Not needed.
                    CustomFieldSelected = true;

                    if (CustomFieldManager.GetByProjectId(ProjectId).Count > 0)
                    {
                        dropField.DataSource = CustomFieldManager.GetByProjectId(ProjectId);
                        dropField.DataTextField = "Name";
                        dropField.DataValueField = "Name";
                        dropField.DataBind();// bind to the new data source.
                        dropField.Items.Add(GetGlobalResourceObject("SharedResources", "DropDown_ResetFields").ToString());
                        dropField.Items.Insert(0, new ListItem(GetGlobalResourceObject("SharedResources", "DropDown_SelectCustomField").ToString(), "0"));
                    }
                    break;
                default:
                    if (dropField.SelectedItem.Text.Equals(GetGlobalResourceObject("SharedResources", "DropDown_SelectCustomField").ToString())) return;

                    // The user decides to reset the fields
                    if (dropField.SelectedItem.Text.Equals(GetGlobalResourceObject("SharedResources", "DropDown_ResetFields").ToString()))
                    {
                        dropField.DataSource = null;
                        dropField.DataSource = RequiredFieldManager.GetRequiredFields();
                        dropField.DataTextField = "Name";
                        dropField.DataValueField = "Value";
                        dropField.DataBind();
                    }

                    //RW Once the list is populated with any varying type of name,
                    //we just default to this case, because we know it is not a standard field.	
                    else
                    {
                        //check the type of this custom field and load the appropriate values.
                        var cf = CustomFieldManager.GetByProjectId(ProjectId).Find(c => c.Name == dropField.SelectedValue);

                        if (cf == null) return;

                        CustomFieldSelected = true;
                        CustomFieldId = cf.Id;
                        CustomFieldDataType = cf.DataType;

                        switch (cf.FieldType)
                        {
                            case CustomFieldType.DropDownList:
                                dropValue.Visible = true;
                                dropValue.DataSource = CustomFieldSelectionManager.GetByCustomFieldId(cf.Id);
                                dropValue.DataTextField = "Name";
                                dropValue.DataValueField = "Value";
                                break;
                            case CustomFieldType.Date:
                                DateValue.Visible = true;
                                break;
                            case CustomFieldType.YesNo:
                                dropValue.Visible = true;
                                dropValue.Items.Add(new ListItem(GetGlobalResourceObject("SharedResources", "DropDown_SelectOne").ToString()));
                                dropValue.Items.Add(new ListItem(GetGlobalResourceObject("SharedResources", "Yes").ToString(), Boolean.TrueString));
                                dropValue.Items.Add(new ListItem(GetGlobalResourceObject("SharedResources", "No").ToString(), Boolean.FalseString));
                                break;
                            default:
                                txtValue.Visible = true;
                                break;
                        }
                    }
                    break;
            }
            try
            {
                dropValue.DataBind();
            }
            catch { }
        }
예제 #9
0
        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        public void DataBind()
        {
            if(this.DataSource.Count > 0)
            {
                if (!string.IsNullOrEmpty(gvIssues.SortField))
                {
                   _DataSource.Sort(new ObjectComparer<Issue>(gvIssues.SortField, true));
                }

                gvIssues.Visible = true;
                pager.Visible = true;
                ScrollPanel.Visible = true;

                int pId = -1;
                if (Request.QueryString["pid"] != null)
                    pId = Int32.Parse(Request.QueryString["pid"]);

                //get custom fields for project
                if (pId != -1)
                {
                    List<CustomField> customFields = CustomFieldManager.GetByProjectId(pId);

                    int nrColumns = FixedColumns;
                    //checks if its initial load to add custom controls and checkboxes
                    if (gvIssues.Columns.Count <= nrColumns + 1)
                    {
                        //if there is custom fields add them
                        if (customFields.Count > 0)
                        {
                            //ctlCustomFields.DataSource = customFields;
                           // ctlCustomFields.DataBind();

                            foreach (CustomField value in customFields)
                            {
                                //increments nr of columns
                                nrColumns++;

                                //create checkbox item
                                ListItem lstValue = new ListItem(value.Name, nrColumns.ToString());

                                //find custom controls that has been checked and check them
                                bool selected = Array.IndexOf(_arrIssueColumns, nrColumns.ToString()) >= 0;
                                if (selected)
                                    lstValue.Selected = true;

                                //add item to checkbox list
                                lstIssueColumns.Items.Add(lstValue);

                                //create column for custom control
                                TemplateField tf = new TemplateField();
                                tf.HeaderText = value.Name;
                                //tf.SortExpression = value.Name;
                                gvIssues.Columns.Add(tf);

                            }
                        }

                    }
                }

                DisplayColumns();
                SelectColumnsPanel.Visible = true;
                lblResults.Visible=false;

                if (ShowProjectColumn)
                {
                    gvIssues.Columns[0].Visible = false;
                    LeftButtonContainerPanel.Visible = false;
                }
                else
                {
                    gvIssues.Columns[4].Visible = false;
                    lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));

                    int projectId = ((Issue)_DataSource[0]).ProjectId;

                    //hide votes column if issue voting is disabled
                    if (!ProjectManager.GetById(projectId).AllowIssueVoting)
                    {
                        gvIssues.Columns[4].Visible = false;
                        lstIssueColumns.Items.Remove(lstIssueColumns.Items.FindByValue("4"));
                    }

                    if (Page.User.Identity.IsAuthenticated && UserManager.HasPermission(projectId, Globals.Permission.EditIssue.ToString()))
                    {
                        LeftButtonContainerPanel.Visible = true;
                    }
                    else
                    {
                        //hide selection column for unauthenticated users
                        gvIssues.Columns[0].Visible = false;
                        LeftButtonContainerPanel.Visible = false;
                    }

                    CategoryTree categories = new CategoryTree();
                    dropCategory.DataSource = categories.GetCategoryTreeByProjectId(projectId);
                    dropCategory.DataBind();
                    dropMilestone.DataSource = MilestoneManager.GetByProjectId(projectId);
                    dropMilestone.DataBind();
                    dropAffectedMilestone.DataSource = MilestoneManager.GetByProjectId(projectId);
                    dropAffectedMilestone.DataBind();
                    dropOwner.DataSource = UserManager.GetUsersByProjectId(projectId);
                    dropOwner.DataBind();
                    dropPriority.DataSource = PriorityManager.GetByProjectId(projectId);
                    dropPriority.DataBind();
                    dropStatus.DataSource = StatusManager.GetByProjectId(projectId);
                    dropStatus.DataBind();
                    dropType.DataSource = IssueTypeManager.GetByProjectId(projectId);
                    dropType.DataBind();
                    dropAssigned.DataSource = UserManager.GetUsersByProjectId(projectId);
                    dropAssigned.DataBind();
                    dropResolution.DataSource = ResolutionManager.GetByProjectId(projectId);
                    dropResolution.DataBind();
                }

                foreach (string colIndex in _arrIssueColumns)
                {
                    ListItem item = lstIssueColumns.Items.FindByValue(colIndex);
                    if (item != null)
                        item.Selected = true;
                }

                gvIssues.DataSource = this.DataSource;
                gvIssues.DataBind();

                InsertCustomFieldData();

            }
            else
            {
                ScrollPanel.Visible = false;
                OptionsContainerPanel.Visible = false;
                lblResults.Visible = true;
                gvIssues.Visible = false;
                pager.Visible = false;
            }
        }