Esempio n. 1
0
        /// <summary>
        /// Binds the issues.
        /// </summary>
        protected void BindIssues()
        {
            bool isError = false;
            List<Issue> colIssues = null;

            //only do this if the user came from the project summary page.
               //only do this if the user came from the project summary or default page.
               //if ((Request.UrlReferrer != null) &&
            //   (Request.UrlReferrer.ToString().Contains("ProjectSummary") || Request.UrlReferrer.ToString().Contains("Default") && Request.QueryString.Count > 1))
               //if (Request.UrlReferrer != null && Request.UrlReferrer.ToString().Contains("ProjectSummary") && Request.QueryString.Count > 1)

               //if ((Request.UrlReferrer != null) &&
              //(!Request.UrlReferrer.ToString().Contains("IssueList") && Request.QueryString.Count > 1 && dropView.SelectedIndex == 0))
               if (Request.QueryString.Count > 1 && dropView.SelectedIndex == 0)
               {
               dropView.SelectedIndex = 0;
               QueryClause q;
               bool isStatus = false;
               string BooleanOperator = "AND";
               List<QueryClause> queryClauses = new List<QueryClause>();
               if (!string.IsNullOrEmpty(IssueCategoryId))
               {
                   if (IssueCategoryId == "0")
                   {
                       q = new QueryClause(BooleanOperator, "IssueCategoryId", "IS", null, SqlDbType.Int, false);
                   }
                   else
                   {
                       q = new QueryClause(BooleanOperator, "IssueCategoryId", "=", IssueCategoryId.ToString(), SqlDbType.Int, false);
                   }
                   queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(IssueTypeId))
               {
                   q = new QueryClause(BooleanOperator, "IssueTypeId", "=", IssueTypeId.ToString(), SqlDbType.Int, false);
                   queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(IssueMilestoneId))
               {
                   //if zero, do a null comparison.
                   if (IssueMilestoneId == "0")
                   {
                       q = new QueryClause(BooleanOperator, "IssueMilestoneId", "IS", null, SqlDbType.Int, false);
                   }
                   else
                   {
                       q = new QueryClause(BooleanOperator, "IssueMilestoneId", "=", IssueMilestoneId, SqlDbType.Int, false);
                   }
                   queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(IssueResolutionId))
               {
                   q = new QueryClause(BooleanOperator, "IssueResolutionId", "=", IssueResolutionId.ToString(), SqlDbType.Int, false);
                   queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(IssuePriorityId))
               {
                   q = new QueryClause(BooleanOperator, "IssuePriorityId", "=", IssuePriorityId.ToString(), SqlDbType.Int, false);
                   queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(IssueStatusId))
               {
                   if (IssueStatusId != "-1")
                   {
                       isStatus = true;
                       q = new QueryClause(BooleanOperator, "IssueStatusId", "=", IssueStatusId.ToString(), SqlDbType.Int, false);
                       queryClauses.Add(q);
                   }
                   else
                   {
                       isStatus = true;
                       List<Status> closedStatus = Status.GetStatusByProjectId(ProjectId).FindAll(s => !s.IsClosedState);
                       foreach (Status status in closedStatus)
                           queryClauses.Add(new QueryClause("AND", "IssueStatusId", "<>", status.Id.ToString(), SqlDbType.Int, false));
                   }

                   //q = new QueryClause(BooleanOperator, "IssueStatusId", "=", IssueStatusId.ToString(), SqlDbType.Int, false);
                   //queryClauses.Add(q);
               }
               if (!string.IsNullOrEmpty(AssignedUserId))
               {
                   if (AssignedUserId == "0")
                       q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "IS", null, SqlDbType.NVarChar, false);
                   else
                       q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "=", AssignedUserId, SqlDbType.NVarChar, false);

                   queryClauses.Add(q);
               }

               //exclude all closed status's
               if (!isStatus)
               {
                   List<Status> status = Status.GetStatusByProjectId(ProjectId).FindAll(delegate(Status s) { return s.IsClosedState == true; });
                   foreach (Status st in status)
                   {
                       q = new QueryClause(BooleanOperator, "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false);
                       queryClauses.Add(q);
                   }
               }

               //q = new QueryClause(BooleanOperator, "new", "=", "another one", SqlDbType.NVarChar, true);
               //queryClauses.Add(q);
               try
               {
                   colIssues = Issue.PerformQuery(ProjectId, queryClauses);

                   // TODO: WARNING Potential Cross Site Scripting attack
                   // also this code only runs if the previous code does not freak out
                   ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?{0}&channel=7", Request.QueryString.ToString());
               }
               catch
               {
                   // BGN-1379
                   // This URL http://localhost/BugNET/Issues/IssueList.aspx?pid=96&c=4471%27;
                   // Generates a Input string was not in a correct format exception in
                   // Source File:  C:\Development\BugNET 0.7.921 SVN Source\branches\BugNET 0.8\src\BugNET_WAP\Old_App_Code\DAL\SqlDataProvider.cs    Line:  4932
                   // Line 4932:                gcfr(sqlCmd.ExecuteReader(), ref List);
                   isError = true;

                   // perhaps this should rather ErrorRedirector.TransferToErrorPage(Page);
                   // but an empty grid with "There are no issues that match your criteria." looks
                   // nice too
               }
               }
               else
               {

               switch (dropView.SelectedValue)
               {
                   case "Relevant":
                       colIssues = Issue.GetIssuesByRelevancy(ProjectId, User.Identity.Name);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=8", ProjectId);
                       break;
                   case "Assigned":
                       colIssues = Issue.GetIssuesByAssignedUserName(ProjectId, User.Identity.Name);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=9", ProjectId);
                       break;
                   case "Owned":
                       colIssues = Issue.GetIssuesByOwnerUserName(ProjectId, User.Identity.Name);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=10", ProjectId);
                       break;
                   case "Created":
                       colIssues = Issue.GetIssuesByCreatorUserName(ProjectId, User.Identity.Name);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=11", ProjectId);
                       break;
                   case "All":
                       colIssues = Issue.GetIssuesByProjectId(ProjectId);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=12", ProjectId);
                       break;
                   case "Open":
                       colIssues = Issue.GetOpenIssues(ProjectId);
                       ctlDisplayIssues.RssUrl = string.Format("~/Rss.aspx?pid={0}&channel=14", ProjectId);
                       break;
                   default:
                       colIssues = new List<Issue>();
                       break;
               }
               }

               if (!isError)
               {

               ctlDisplayIssues.DataSource = colIssues;

               if (Request.QueryString["cr"] != null)
                   colIssues.Sort(new IssueComparer("Created", true));

               if (Request.QueryString["ur"] != null)
                   colIssues.Sort(new IssueComparer("LastUpdate", true));

               ctlDisplayIssues.DataBind();
               }
        }
Esempio n. 2
0
        /// <summary>
        /// Performs the issue search and populates mainIssues and mainComment.
        /// </summary>
        /// <param name="srchprj">A List of projects to search through.</Project>.</param>
        private void PerformIssueSearch(List<Project> srchprj)
        {
            List<IssueComment> foundComments = new List<IssueComment>();
            List<IssueComment> IssueComments = new List<IssueComment>();
            List<IssueHistory> lstMainHistory = new List<IssueHistory>();

            // Our search strings on normal and "like" comparators
            // Note: these are deliberately not trimmed!
            // to the users, "test" might be different from "test "
            string strSearch = txtSearch.Text;
            string strLike = "%" + strSearch + "%";
            string strHtmlSearch = Server.HtmlEncode(strSearch);
            string strHtmlLike = "%" + strHtmlSearch + "%";

            // if the two strings are equal srchHtmlcode is false
            // If they are not equal, then I need to search for the HTML encoded
            // variants later on.
            bool srchHtmlcode = !(strHtmlSearch == strSearch);

            bool srchComments = chkComments.Checked;
            bool srchOpenIssues = chkExcludeClosedIssues.Checked;
            bool srchUserName = false;//= chkUsername.Checked ; // not implemented
            bool srchCommentUserName = false;// chkCommentUsername.Checked;

            bool srchHistory = false; //  chkHistory.Checked;

            // Sort the projects using LINQ
            foreach (Project p in srchprj)
            {
                // now search each project with wildcard parameters
                // (except for the search string)

                // ---------------------------------------------------------------
                // Normal Search
                //
                // Searches Description, Issue Title using a LIKE query
                // If you are searching username it adds the LastUpdateUsername,
                // AssignedUsername, CreatorUserName, OwnerUserName to the list.
                //
                // ---------------------------------------------------------------

                List<QueryClause> queryClauses = new List<QueryClause>();

                // NOTE WE ARE OPENING A PARENTHISES using the
                // "William Highfield" trick ;)
                //
                // SQL Statement constructed by the QueryBuilder will nned to be something like
                // SELECT something FROM somewhere WHERE 1=1 AND ( IssueDescription LIKE '%test%' OR IssueTitle LIKE '%test%' )
                //
                // The parenthesis ensure this, however you need to close the parenthesis off properly.

                QueryClause q = new QueryClause("AND (", "IssueDescription", "LIKE", strLike, SqlDbType.NVarChar, false);
                queryClauses.Add(q);
                q = new QueryClause("OR", "IssueTitle", "LIKE", strLike, SqlDbType.NVarChar, false);
                queryClauses.Add(q);

                if (srchHtmlcode)
                {
                    q = new QueryClause("OR", "IssueDescription", "LIKE", strHtmlLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);
                    q = new QueryClause("OR", "IssueTitle", "LIKE", strHtmlLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);
                }

                // USERNAME
                if (srchUserName)
                {
                    /*
                     *
                    q = new QueryClause("OR", "LastUpdateUsername", "LIKE", strLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);

                    q = new QueryClause("OR", "AssignedUsername", "LIKE", strLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);

                    q = new QueryClause("OR", "CreatorUserName", "LIKE", strLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);

                    q = new QueryClause("OR", "OwnerUserName", "LIKE", strLike, SqlDbType.NVarChar, false);
                    queryClauses.Add(q);
                     *
                     */
                }

                // NOW TO CLOSE PARENTHISES
                //
                // Using the "William Highfield" trick ;)
                //
                q = new QueryClause(")", "", "", "", SqlDbType.NVarChar, false);
                queryClauses.Add(q);

                // Use the new Generic way to search with those QueryClauses
                List<Issue> Issues = Issue.PerformQuery(p.Id, queryClauses);

                // Now we can quicjkly filter out open issues
                if (srchOpenIssues)
                {

                    // get list of open issues for the project using LINQ
                    var tmpIssues = from iss in Issues
                                    join st in Status.GetStatusByProjectId(p.Id)
                                    on iss.StatusId equals st.Id
                                    where st.IsClosedState == false
                                    select iss;

                    mainIssues.AddRange(tmpIssues);

                }
                else
                {
                    mainIssues.AddRange(Issues);
                }

                //if (srchComments /*|| srchHistory*/ )
                //{
                //    // Get the Issues by Project now so
                //    // we dont have repeated fetches if the user
                //    // selects multiple options.

                //    // we need to search the projects again becuase bc only contains our search results
                //    Issues = Issue.GetIssuesByProjectId(p.Id);
                //}

                // ---------------------------------------------------------------
                // Search History
                //
                // ---------------------------------------------------------------
                // List<IssueHistory> lstprjHistory = null;
                if (srchHistory)
                {
                    /*
                    lstprjHistory = new List<IssueHistory>();
                    queryClauses.Clear();
                    // bug need highfield method
                    queryClauses.Add(new QueryClause("AND", "OldValue", "LIKE", strLike , SqlDbType.VarChar, false));
                    queryClauses.Add(new QueryClause("OR", "NewValue", "LIKE", strLike, SqlDbType.VarChar, false));
                    queryClauses.Add(new QueryClause("AND", "c.ProjectID", "=", p.Id.ToString(), SqlDbType.Int, false));
                    lstprjHistory = IssueHistory.PerformQuery(queryClauses);

                    // Now we can quicjkly filter out open issues
                    if (srchOpenIssues)
                    {

                        // get list of open issues with matching history items for the project using LINQ
                        var tmpIssues = from hist in lstprjHistory
                                        join iss1 in Issue.GetIssuesByProjectId(p.Id)
                                        on hist.Id equals iss1.Id
                                        join st in Status.GetStatusByProjectId(p.Id)
                                        on iss1.StatusId equals st.Id
                                        where st.IsClosedState = false
                                        select iss1;

                        mainIssues.AddRange(tmpIssues);

                    }
                    else
                    {
                        mainIssues.AddRange(Issues);
                    }

                    throw new NotImplementedException();
                    */
                }

                // ---------------------------------------------------------------
                // Search Comments
                //
                // ---------------------------------------------------------------

                if (srchComments)
                {
                    IssueComments.Clear();
                    foundComments.Clear();

                    // Get ALL issues
                    Issues = Issue.GetIssuesByProjectId(p.Id);

                    // Now filter out the Closed issues if we need to
                    if (srchOpenIssues)
                    {
                        // get list of open issues with matching history items for the project using LINQ
                        var tmpIssues = from Iss in Issues
                                        join st in Status.GetStatusByProjectId(p.Id)
                                        on Iss.StatusId equals st.Id
                                        where st.IsClosedState = false
                                        select Iss;

                        List<Issue> tmpIssueList = new List<Issue>();
                        tmpIssueList.AddRange(tmpIssues);

                        Issues.Clear();
                        Issues.AddRange(tmpIssueList);
                        // Issues now only has open issues
                    }

                    foreach (Issue iss in Issues)
                    {
                        // New Way
                        // Using the Generic Interface
                        List<QueryClause> qryComment = new List<QueryClause>();

                        // NOTE WE ARE OPENING A PARENTHISES using the
                        // "William Highfield" trick ;)
                        // see earlier in this code

                        q = new QueryClause("AND (", "Comment", "LIKE", strLike, SqlDbType.VarChar, false);
                        qryComment.Add(q);

                        if (srchHtmlcode)
                        {
                            q = new QueryClause("OR", "Comment", "LIKE", strHtmlLike, SqlDbType.VarChar, false);
                            qryComment.Add(q);
                        }

                        // NOW TO CLOSE PARENTHISES
                        //
                        // Using the "William Highfield" trick ;)
                        //
                        q = new QueryClause(")", "", "", "", SqlDbType.NVarChar, false);
                        qryComment.Add(q);

                            //if (srchUserName)
                            //{
                            //    q = new QueryClause("OR", "CreatorUsername", "LIKE", "%" + strSearch + "%", SqlDbType.VarChar, false);
                            //    qryComment.Add(q);
                            //}

                        IssueComments = IssueComment.PerformQuery(iss.Id, qryComment);

                        // Did we find anything?
                        if (IssueComments.Count > 0)
                        {

                                mainComments.AddRange(IssueComments);
                            mainIssues.Add(iss);
                            // make sure we record the parent issue of the comment(s)
                        }
                    }

                }

                //if (srchHistory && (lstprjHistory != null))
                //{
                //   // lstMainHistory.AddRange(lstprjHistory);
                //}
            } // foreach project

            // ---------------------------------------------------------------
            // Clean up duplicates and sort
            //
            // mainIssues and mainComments
            // Sorry for the horrible variable names
            //
            // ---------------------------------------------------------------
            var tmpIss = (from iss1 in mainIssues
                          orderby iss1.ProjectId, iss1.Id descending
                          select iss1).Distinct(new DistinctIssueComparer());

            List<Issue> tmpIssues1 = new List<Issue>();
            tmpIssues1.AddRange(tmpIss);
            mainIssues.Clear();
            mainIssues.AddRange(tmpIssues1);

            // mainIssues list should be pure now

            var tmpComm = (from comm in mainComments
                           orderby comm.IssueId, comm.Id
                           select comm)
                           .Distinct();

            List<IssueComment> tmpComm1 = new List<IssueComment>();
            tmpComm1.AddRange(tmpComm);
            mainComments.Clear();
            mainComments.AddRange(tmpComm1);
        }
Esempio n. 3
0
        private void FilteredIssuesFeed()
        {
            QueryClause q;
            bool isStatus = false;
            string BooleanOperator = "AND";
            List<QueryClause> queryClauses = new List<QueryClause>();
            //if (!string.IsNullOrEmpty(IssueCategoryId))
            //{
            //    q = new QueryClause(BooleanOperator, "IssueCategoryId", "=", IssueCategoryId.ToString(), SqlDbType.Int, false);
            //    queryClauses.Add(q);
            //}
            if (!string.IsNullOrEmpty(IssueTypeId))
            {
                q = new QueryClause(BooleanOperator, "IssueTypeId", "=", IssueTypeId.ToString(), SqlDbType.Int, false);
                queryClauses.Add(q);
            }
            if (!string.IsNullOrEmpty(IssueMilestoneId))
            {
                //if zero, do a null comparison.
                if (IssueMilestoneId == "0")
                    q = new QueryClause(BooleanOperator, "IssueMilestoneId", "IS", null, SqlDbType.Int, false);
                else
                    q = new QueryClause(BooleanOperator, "IssueMilestoneId", "=", IssueMilestoneId, SqlDbType.Int, false);

                queryClauses.Add(q);
            }
            if (!string.IsNullOrEmpty(IssueResolutionId))
            {
                q = new QueryClause(BooleanOperator, "IssueResolutionId", "=", IssueResolutionId.ToString(), SqlDbType.Int, false);
                queryClauses.Add(q);
            }
            if (!string.IsNullOrEmpty(IssuePriorityId))
            {
                q = new QueryClause(BooleanOperator, "IssuePriorityId", "=", IssuePriorityId.ToString(), SqlDbType.Int, false);
                queryClauses.Add(q);
            }
            if (!string.IsNullOrEmpty(IssueStatusId))
            {
                isStatus = true;
                q = new QueryClause(BooleanOperator, "IssueStatusId", "=", IssueStatusId.ToString(), SqlDbType.Int, false);
                queryClauses.Add(q);
            }
            if (!string.IsNullOrEmpty(AssignedUserName))
            {
                if(AssignedUserName == "0")
                    q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "IS",null, SqlDbType.NVarChar, false);
                else
                    q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "=", AssignedUserName, SqlDbType.NVarChar, false);
                queryClauses.Add(q);
            }

            //exclude all closed status's
            if (!isStatus)
            {
                List<Status> status = Status.GetStatusByProjectId(projectId).FindAll(delegate(Status s) { return s.IsClosedState == true; });
                foreach (Status st in status)
                {
                    q = new QueryClause(BooleanOperator, "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false);
                    queryClauses.Add(q);
                }
            }
            //q = new QueryClause(BooleanOperator, "new", "=", "another one", SqlDbType.NVarChar, true);
            //queryClauses.Add(q);
            colIssues = Issue.PerformQuery(projectId, queryClauses);

            foreach (Issue issue in colIssues)
            {
                RssItem item = new RssItem();
                item.Title = string.Format("{0} - {1}", issue.FullId, issue.Title);
                item.Description = issue.Description;
                item.Author = issue.CreatorUserName;
                item.PubDate = issue.DateCreated;
                item.Link = new System.Uri(string.Format("{0}Issues/IssueDetail.aspx?id={1}", HostSetting.GetHostSetting("DefaultUrl"), issue.Id.ToString()));
                channel.Items.Add(item);
            }

            channel.Title = projectName + " - Issues";
            if (!string.IsNullOrEmpty(User.Identity.Name)) {
               channel.Title += " (generated for " + Security.GetDisplayName() + ")";
            }

            channel.Description = string.Format("Issues for {0}",projectName);
        }
Esempio n. 4
0
        /// <summary>
        /// This method adds a new query clause to the user interface.
        /// </summary>
        /// <param name="bindData">if set to <c>true</c> [bind data].</param>
        void AddClause(bool bindData, QueryClause queryClause)
        {
            PickQueryField ctlPickQueryField = (PickQueryField)Page.LoadControl( "~/UserControls/PickQueryField.ascx");

            plhClauses.Controls.Add( ctlPickQueryField );
            ctlPickQueryField.ProjectId = ProjectId;
            if(bindData)
                ctlPickQueryField.QueryClause = queryClause;
        }
        /// <summary>
        /// Handles the Click event of the OkButton 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 OkButton_Click(object sender, EventArgs e)
        {
            int OldCategoryId = 0;
            if(!string.IsNullOrEmpty(HiddenField1.Value))
                OldCategoryId = Convert.ToInt32(HiddenField1.Value);

            if (OldCategoryId != 0)
            {
                List<QueryClause> queryClauses = new List<QueryClause>();
                QueryClause q = new QueryClause("AND", "IssueCategoryId", "=", HiddenField1.Value, SqlDbType.Int, false);
                queryClauses.Add(q);

                List<Issue> issues = Issue.PerformQuery(ProjectId, queryClauses);
                if (RadioButton1.Checked) //delete category
                {
                    //delete all issues first
                    foreach (Issue issue in issues)
                        Issue.DeleteIssue(issue.Id);

                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);
                }

                if (RadioButton2.Checked) //reassign issues to existing category.
                {
                    if (DropCategory.SelectedValue == 0)
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("NoCategorySelected").ToString());
                        return;
                    }
                    if (OldCategoryId == DropCategory.SelectedValue)
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("SameCategorySelected").ToString());
                        return;
                    }

                    foreach (Issue issue in issues)
                    {
                        issue.CategoryName = DropCategory.SelectedText;
                        issue.CategoryId = DropCategory.SelectedValue;
                        issue.Save();
                    }

                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);
                }

                //assign new category
                if (RadioButton3.Checked)
                {
                    if(string.IsNullOrEmpty(NewCategoryTextBox.Text))
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("NewCategoryNotEntered").ToString());
                        return;
                    }
                    Category c = new Category(ProjectId, 0, NewCategoryTextBox.Text, 0);
                    c.Save();
                    foreach (Issue issue in issues)
                    {
                        issue.CategoryName = NewCategoryTextBox.Text;
                        issue.CategoryId = c.Id;
                        issue.Save();
                    }
                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);

                }
            }
            else
            {
                Message1.ShowErrorMessage(GetLocalResourceObject("CannotDeleteRootCategory").ToString());
                return;
            }
        }
        /// <summary>
        /// Handles the DayRender event of the prjCalendar control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DayRenderEventArgs"/> instance containing the event data.</param>
        protected void prjCalendar_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
        {
            string onmouseoverStyle = "this.style.backgroundColor='#D4EDFF'";
            string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
            string rowBackColor = string.Empty;

            if(!e.Day.IsWeekend)
            {
                e.Cell.Attributes.Add("onmouseover", onmouseoverStyle);
                if(!e.Day.IsSelected)
                    e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));
                else
                    e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", "#FFFFC1"));
            }

            if (e.Day.IsToday)
            {
                //TODO: If issues are due today in 7 days or less then create as red, else use blue?
            }

            List<QueryClause> queryClauses = new List<QueryClause>();
            switch (dropView.SelectedValue)
            {
                case "IssueDueDates":
                    QueryClause q = new QueryClause("AND", "IssueDueDate", "=", e.Day.Date.ToShortDateString(), SqlDbType.DateTime, false);
                    queryClauses.Add(q);

                    List<Issue> issues = Issue.PerformQuery(ProjectId, queryClauses);
                    foreach (Issue issue in issues)
                    {
                        if (issue.Visibility == (int)Globals.IssueVisibility.Private && issue.AssignedDisplayName != Security.GetUserName() && issue.CreatorDisplayName != Security.GetUserName() && (!ITUser.IsInRole(Globals.SuperUserRole) || !ITUser.IsInRole(Globals.ProjectAdminRole)))
                            continue;

                        string cssClass = string.Empty;

                        if (issue.DueDate <= DateTime.Today)
                            cssClass = "calIssuePastDue";
                        else
                            cssClass = "calIssue";

                        if (issue.Visibility == (int)Globals.IssueVisibility.Private)
                            cssClass += " calIssuePrivate";

                        string title = string.Format(@"<div id=""issue"" class=""{3}""><a href=""../Issues/IssueDetail.aspx?id={2}"">{0} - {1}</a></div>", issue.FullId.ToUpper(), issue.Title, issue.Id,cssClass);
                        e.Cell.Controls.Add(new LiteralControl(title));
                    }
                    break;
                case "MilestoneDueDates":
                    List<Milestone> milestones = Milestone.GetMilestoneByProjectId(ProjectId).FindAll(m => m.DueDate == e.Day.Date);
                    foreach (Milestone m in milestones)
                    {
                        string cssClass = string.Empty;

                        if (m.DueDate <= DateTime.Today)
                            cssClass = "calIssuePastDue";
                        else
                            cssClass = "calIssue";

                        string projectName = Project.GetProjectById(ProjectId).Name;
                        string title = string.Format(@"<div id=""issue"" class=""{4}""><a href=""../Issues/IssueList.aspx?pid={2}&m={3}"">{1} - {0} </a><br/>{5}</div>",m.Name,projectName,m.ProjectId,m.Id, cssClass,m.Notes);
                        e.Cell.Controls.Add(new LiteralControl(title));
                    }
                    break;

            }

            //Set the calendar to week mode only showing the selected week.
            if (dropCalendarView.SelectedValue == "Week")
            {
                if (Week(e.Day.Date) != Week(prjCalendar.VisibleDate))
                {
                    e.Cell.Visible = false;
                }
                e.Cell.Height = new Unit("300px");
            }
            else
            {
                //e.Cell.Height = new Unit("80px");
                //e.Cell.Width = new Unit("80px");
            }
        }
        public object[] GetProjectIssues(int ProjectId, string Filter)
        {
            if (Project.GetProjectById(ProjectId).AccessType == Globals.ProjectAccessType.Private && !Project.IsUserProjectMember(UserName, ProjectId))
               throw new UnauthorizedAccessException(string.Format("The user {0} does not have permission to this project.", UserName)); //TODO: Get this from resource string

               List<Issue> issues;
               QueryClause q;
               List<QueryClause> queryClauses = new List<QueryClause>();
               string BooleanOperator = "AND";

               if (Filter.Trim() == "")
               {
               // Return all Issues
               issues = Issue.GetIssuesByProjectId(ProjectId);
               }
               else
               {
               foreach (string item in Filter.Split('&'))
               {
                   if (item.StartsWith("status=", StringComparison.CurrentCultureIgnoreCase))
                   {
                       if (item.EndsWith("=notclosed", StringComparison.CurrentCultureIgnoreCase))
                       {
                           List<Status> status = Status.GetStatusByProjectId(ProjectId).FindAll(delegate(Status s) { return s.IsClosedState == true; });
                           foreach (Status st in status)
                           {
                               q = new QueryClause(BooleanOperator, "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false);
                               queryClauses.Add(q);
                           }
                       }
                       else if (item.EndsWith("=new", StringComparison.CurrentCultureIgnoreCase))
                       {
                           q = new QueryClause(BooleanOperator, "AssignedUsername", "=", "none", SqlDbType.NVarChar, false);
                           queryClauses.Add(q);
                           List<Status> status = Status.GetStatusByProjectId(ProjectId).FindAll(delegate(Status s) { return s.IsClosedState == true; });
                           foreach (Status st in status)
                           {
                               q = new QueryClause(BooleanOperator, "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false);
                               queryClauses.Add(q);
                           }
                       }
                   }
                   else if (item.StartsWith("owner=", StringComparison.CurrentCultureIgnoreCase))
                   {
                       q = new QueryClause(BooleanOperator, "OwnerUsername", "=", item.Substring(item.IndexOf('=') + 1, item.Length - item.IndexOf('=') - 1).ToString(), SqlDbType.NVarChar, false);
                       queryClauses.Add(q);
                   }
                   else if (item.StartsWith("reporter=", StringComparison.CurrentCultureIgnoreCase))
                   {
                       q = new QueryClause(BooleanOperator, "CreatorUsername", "=", item.Substring(item.IndexOf('=') + 1, item.Length - item.IndexOf('=') - 1).ToString(), SqlDbType.NVarChar, false);
                       queryClauses.Add(q);
                   }
                   else if (item.StartsWith("assigned=", StringComparison.CurrentCultureIgnoreCase))
                   {
                       q = new QueryClause(BooleanOperator, "AssignedUsername", "=", item.Substring(item.IndexOf('=') + 1, item.Length - item.IndexOf('=') - 1).ToString(), SqlDbType.NVarChar, false);
                       queryClauses.Add(q);
                   }
               }
               issues = Issue.PerformQuery(ProjectId, queryClauses);
               }

               List<Object> issueList = new List<Object>();
               Object[] issueitem;
               foreach (Issue item in issues)
               {
               issueitem = new Object[13];
               issueitem[0] = item.Id;
               issueitem[1] = item.DateCreated;
               issueitem[2] = item.LastUpdate;
               issueitem[3] = item.StatusName;
               issueitem[4] = item.Description;
               issueitem[5] = item.CreatorUserName;
               issueitem[6] = item.ResolutionName;
               issueitem[7] = item.CategoryName;
               issueitem[8] = item.Title;
               issueitem[9] = item.PriorityName;
               issueitem[10] = item.MilestoneName;
               issueitem[11] = item.OwnerUserName;
               issueitem[12] = item.IssueTypeName;
               issueList.Add(issueitem);
               }
               return issueList.ToArray();
        }