Beispiel #1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    IList <string> segments = Request.GetFriendlyUrlSegments();
                    ProjectId = Int32.Parse(segments[0]);
                }
                catch
                {
                    ProjectId = Request.QueryString.Get("pid", 0);
                }

                // If don't know project or issue then redirect to something missing page
                if (ProjectId == 0)
                {
                    ErrorRedirector.TransferToSomethingMissingPage(Page);
                }

                CurrentProject      = ProjectManager.GetById(ProjectId);
                litProject.Text     = CurrentProject.Name;
                litProjectCode.Text = CurrentProject.Code;

                if (CurrentProject == null)
                {
                    ErrorRedirector.TransferToNotFoundPage(Page);
                    return;
                }

                //security check: add issue
                if (!UserManager.HasPermission(ProjectId, Common.Permission.AddIssue.ToString()))
                {
                    ErrorRedirector.TransferToLoginPage(Page);
                }

                BindOptions();
                BindDefaultValues();

                //check users role permission for adding an attachment
                if (!Page.User.Identity.IsAuthenticated || !UserManager.HasPermission(ProjectId, Common.Permission.AddAttachment.ToString()))
                {
                    pnlAddAttachment.Visible = false;
                }
                else if (HostSettingManager.Get(HostSettingNames.AllowAttachments, false) && CurrentProject.AllowAttachments)
                {
                    pnlAddAttachment.Visible = true;
                }
            }

            //need to rebind these on every postback because of dynamic controls
            ctlCustomFields.DataSource = CustomFieldManager.GetByProjectId(ProjectId);
            ctlCustomFields.DataBind();

            // The ExpandIssuePaths method is called to handle
            // the SiteMapResolve event.
            SiteMap.SiteMapResolve += ExpandIssuePaths;
        }
        /// <summary>
        /// Binds the custom fields.
        /// </summary>
        private void BindCustomFields()
        {
            //check if we are editing the sub grid - needed to fire update command on the nested grid.
            if (ViewState["EditingSubGrid"] == null)
            {
                grdCustomFields.DataSource   = CustomFieldManager.GetByProjectId(ProjectId);
                grdCustomFields.DataKeyField = "Id";
                grdCustomFields.DataBind();

                grdCustomFields.Visible = grdCustomFields.Items.Count != 0;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Handles the PreRender event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //hide votes column if issue voting is disabled
            if (!ProjectManager.GetById(ProjectId).AllowIssueVoting)
            {
                dropField.Items.Remove(dropField.Items.FindByValue("IssueVotes"));
            }

            if (CustomFieldManager.GetByProjectId(ProjectId).Count == 0)
            {
                dropField.Items.Remove("CustomFieldName");
            }
        }
Beispiel #4
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 { }
        }
Beispiel #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;
            }
        }