Esempio n. 1
0
        /// <summary>
        /// Binds the milestones.
        /// </summary>
        private void BindResolutions()
        {
            grdResolutions.Columns[1].HeaderText = GetGlobalResourceObject("SharedResources", "Resolution").ToString();
            grdResolutions.Columns[2].HeaderText = GetGlobalResourceObject("SharedResources", "Image").ToString();
            grdResolutions.Columns[3].HeaderText = GetGlobalResourceObject("SharedResources", "Order").ToString();

            grdResolutions.DataSource   = ResolutionManager.GetByProjectId(ProjectId);
            grdResolutions.DataKeyField = "Id";
            grdResolutions.DataBind();

            grdResolutions.Visible = grdResolutions.Items.Count != 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();
        }
        public String[] GetResolutions(int ProjectId)
        {
            if (ProjectManager.GetById(ProjectId).AccessType == Common.ProjectAccessType.Private && !ProjectManager.IsUserProjectMember(UserName, ProjectId))
            {
                throw new UnauthorizedAccessException(string.Format(LoggingManager.GetErrorMessageResource("ProjectAccessDenied"), UserName));
            }

            List <Resolution> resolutions = ResolutionManager.GetByProjectId(ProjectId);
            List <String>     returnval   = new List <String>();

            foreach (Resolution item in resolutions)
            {
                returnval.Add(item.Name.ToString());
            }
            return(returnval.ToArray());
        }
Esempio n. 4
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();
        }
Esempio n. 5
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 { }
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Returns a valid project Resolution.
        /// </summary>
        /// <param name="p">A Project</param>
        /// <returns>Random Resolution</returns>
        public Resolution GetResolution()
        {
            List <Resolution> Resolutions = ResolutionManager.GetByProjectId(p.Id);

            return(Resolutions[rng.Next(0, Resolutions.Count)]);
        }
Esempio n. 8
0
 /// <summary>
 /// Handles the Validate event of the ResolutionValidation control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
 protected void ResolutionValidation_Validate(object sender, ServerValidateEventArgs e)
 {
     //validate that at least one Resolution exists.
     e.IsValid = ResolutionManager.GetByProjectId(ProjectId).Count > 0;
 }