Пример #1
0
        private void RefreshBoundData()
        {
            if (SelectedNodePath != "")
            {
                SelectedRecordsType.Text = SelectedNodePath.Replace("Records Types/", "").Replace("/", " / ");

                WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
                WBTaxonomy teams        = WBTaxonomy.GetTeams(recordsTypes);

                WBRecordsType recordsType = recordsTypes.GetSelectedRecordsType(SelectedNodePath);
                SelectedRecordsTypeDescription.Text = recordsType.Description;



                WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web);

                WBFarm farm = WBFarm.Local;

                using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl))
                {
//                    using (SPWeb web = site.OpenWeb())
//                  {

                    WBQuery query = new WBQuery();

                    WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType);
                    recordsTypeClause.UseDescendants = true;
                    query.AddClause(recordsTypeClause);

                    if (team != null)
                    {
                        query.AddEqualsFilter(WBColumn.InvolvedTeams, team);
                    }

                    string statusFilter = Request.QueryString["Status"];
                    if (statusFilter != null && statusFilter != "")
                    {
                        query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter);
                    }

                    query.AddViewColumn(WBColumn.Title);
                    query.AddViewColumn(WBColumn.WorkBoxURL);
                    query.AddViewColumn(WBColumn.OwningTeam);
                    //                        query.AddViewColumn(WBColumn.FunctionalArea);
                    query.AddViewColumn(WBColumn.ReferenceDate);
                    query.AddViewColumn(WBColumn.ReferenceID);
                    query.AddViewColumn(WBColumn.SeriesTag);
                    //                    query.AddViewColumn(WBColumn.InvolvedTeams);
                    query.AddViewColumn(WBColumn.WorkBoxStatus);

                    if (sortColumn != null)
                    {
                        query.OrderBy(sortColumn, ascending);
                    }

                    DataTable dataTable = collection.Query(query);

                    ShowResults.DataSource = dataTable;

                    ShowResults.Columns.Clear();
                    ShowResults.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL));
                    ShowResults.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending));
                    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending));
                    //                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
                    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending));
                    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending));
                    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending));
                    //    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending));
                    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, sortColumn, ascending));


                    ShowResults.DataBind();

                    // }
                }
            }
            else
            {
                WBUtils.logMessage("SelectedNodePath was empty");
            }
        }
        private void RefreshBoundData()
        {
            if (!String.IsNullOrEmpty(SelectedRecordsTypeGUID))
            {
                WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
                WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes);

                WBRecordsType recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID));

                String recordsTypePath = recordsType.FullPath;
                //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1);
                recordsTypePath = recordsTypePath.Replace("/", " / ");

                SelectionTitle.Text = recordsTypePath;
                SelectionDescription.Text = recordsType.Description;

                WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web);

                WBFarm farm = WBFarm.Local;

                using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl))
                {
                    //                    using (SPWeb web = site.OpenWeb())
                    //                  {

                    WBQuery query = new WBQuery();

                    WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType);
                    recordsTypeClause.UseDescendants = false;
                    query.AddClause(recordsTypeClause);

                    if (team != null)
                    {
                        query.AddEqualsFilter(WBColumn.InvolvedTeams, team);
                    }

                    string statusFilter = SelectedWorkBoxStatusFilter;
                    if (statusFilter == null || statusFilter == "") statusFilter = "Open";
                    if (statusFilter != "All")
                    {
                        query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter);
                    }

                    FilterOpenStatus.CssClass = "wbf-unselected-filter";
                    FilterClosedStatus.CssClass = "wbf-unselected-filter";
                    FilterAllStatus.CssClass = "wbf-unselected-filter";

                    if (statusFilter == "Open") FilterOpenStatus.CssClass = "wbf-selected-filter";
                    if (statusFilter == "Closed") FilterClosedStatus.CssClass = "wbf-selected-filter";
                    if (statusFilter == "All") FilterAllStatus.CssClass = "wbf-selected-filter";


                    query.AddViewColumn(WBColumn.Title);
                    query.AddViewColumn(WBColumn.WorkBoxURL);
                    //query.AddViewColumn(WBColumn.OwningTeam);
                    //                        query.AddViewColumn(WBColumn.FunctionalArea);
                    query.AddViewColumn(WBColumn.ReferenceDate);
                    //query.AddViewColumn(WBColumn.ReferenceID);
                    //query.AddViewColumn(WBColumn.SeriesTag);
                    //                    query.AddViewColumn(WBColumn.InvolvedTeams);
                    query.AddViewColumn(WBColumn.WorkBoxStatus);

                    if (sortColumn != null)
                        query.OrderBy(sortColumn, ascending);

                    DataTable dataTable = collection.Query(query);

                    SelectedWorkBoxes.DataSource = dataTable;

                    SelectedWorkBoxes.Columns.Clear();
                    SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL));
                    SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending));
//                    SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending));
                    //                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
                    SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending));
  //                  SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending));
    //                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending));
                    //    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending));
                    SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, sortColumn, ascending));


                    SelectedWorkBoxes.DataBind();



                    if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team))
                    {
                        string createNewURL = collection.GetUrlForNewDialog(recordsType, team);
                        string createNewText = recordsType.CreateNewWorkBoxText;

                        CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>";
                    }
                    else
                    {
                        CreateNewWorkBoxLink.Text = "";
                    }



                    // }
                }
            }
            else
            {
                WBUtils.logMessage("SelectedRecordsTypeGUID was empty");
            }

        }
Пример #3
0
        protected override void Render(HtmlTextWriter writer)
        {
            WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current);

            if (workBox == null)
            {
                errorLiteral.Text = "<i>(You can only use this web part in a work box)</i>";
            }
            else
            {
                WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
                WBTaxonomy seriesTags   = WBTaxonomy.GetSeriesTags(recordsTypes);

                WBTerm thisSeries = workBox.SeriesTag(seriesTags);

                WBQuery query = new WBQuery();

                query.AddEqualsFilter(WBColumn.RecordsType, workBox.RecordsType);

                if (FilterBySeriesTag)
                {
                    query.AddEqualsFilter(WBColumn.SeriesTag, workBox.SeriesTag(seriesTags));
                }

                if (FilterByReferenceID)
                {
                    query.AddEqualsFilter(WBColumn.ReferenceID, workBox.ReferenceID);
                }

                //            if (FilterByOwningTeam)
                //            query.AddEqualsFilter(WBColumn.OwningTeam, workBox.OwningTeam);


                if (sortColumn != null)
                {
                    WBLogging.Debug("Sorting in Render with sortColumn: " + sortColumn.DisplayName);
                }
                else
                {
                    WBLogging.Debug("Sorting Render - sortColumn was null");
                }

                if (sortColumn != null)
                {
                    query.OrderBy(sortColumn, ascending);
                }

                query.AddViewColumn(WBColumn.Title);
                query.AddViewColumn(WBColumn.WorkBoxURL);
                query.AddViewColumn(WBColumn.ReferenceDate);
                query.AddViewColumn(WBColumn.WorkBoxStatus);

                WBColumn testIfIsThisWorkBox = new WBColumn("IfIsThisWorkBox", WBColumn.DataTypes.VirtualConditional);
                testIfIsThisWorkBox.TestColumnInternalName = WBColumn.Title.InternalName;
                testIfIsThisWorkBox.TestColumnValue        = workBox.Title;
                testIfIsThisWorkBox.ValueIfEqual           = "===>";

                query.AddViewColumn(testIfIsThisWorkBox);

                DataTable dataTable = workBox.Collection.Query(query);

                gridView.DataSource = new DataView(dataTable);

                BoundField testIfIsThisWorkBoxField = WBUtils.BoundField(testIfIsThisWorkBox, HorizontalAlign.Center, sortColumn, ascending);
                testIfIsThisWorkBoxField.HeaderText = "     ";

                gridView.Columns.Add(testIfIsThisWorkBoxField);
                gridView.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL));
                gridView.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending));
                gridView.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending));
                gridView.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending));

                gridView.DataBind();


                if (ShowCreateNewLink)
                {
                    string createNewText = workBox.RecordsType.CreateNewWorkBoxText;
                    string createNewURL  = workBox.Collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__DYNAMIC);

                    createNewLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500); \">" + createNewText + "</a>";
                }

                workBox.Dispose();
            }

            base.Render(writer);
        }
Пример #4
0
        private void RefreshBoundData()
        {
            if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE)
            {
                FilterOpenStatus.Enabled   = true;
                FilterClosedStatus.Enabled = true;
                FilterAllStatus.Enabled    = true;
            }
            else
            {
                FilterOpenStatus.Enabled   = false;
                FilterClosedStatus.Enabled = false;
                FilterAllStatus.Enabled    = false;

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ClearHighlightedRecordsTypes", "$('a.ms-navitem').css('font-weight', 'normal');", true);
            }

            WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
            WBTaxonomy teams        = WBTaxonomy.GetTeams(recordsTypes);

            WBQuery query = new WBQuery();

            query.AddViewColumn(WBColumn.Title);
            query.AddViewColumn(WBColumn.WorkBoxURL);
            //query.AddViewColumn(WBColumn.OwningTeam);
            //                        query.AddViewColumn(WBColumn.FunctionalArea);
            //query.AddViewColumn(WBColumn.ReferenceDate);
            //query.AddViewColumn(WBColumn.ReferenceID);
            //query.AddViewColumn(WBColumn.SeriesTag);
            //                    query.AddViewColumn(WBColumn.InvolvedTeams);
            query.AddViewColumn(WBColumn.WorkBoxStatus);

            checkSortState();
            if (sortColumn != null)
            {
                query.OrderBy(sortColumn, ascending);
            }

            SelectedWorkBoxes.Columns.Clear();
            SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL));
            SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending, ""));
            //                    SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending));
            //                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
            // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending));
            //                  SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending));
            //                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending));
            //    ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending));

            switch (SelectedWorkBoxView)
            {
            case VIEW__RECENTLY_CREATED:
            {
                query.AddViewColumn(WBColumn.WorkBoxDateCreated);
                //query.AddViewColumn(WBColumn.RecordsType);
                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateCreated, HorizontalAlign.Center, sortColumn, ascending));
                //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending));

                break;
            }

            case VIEW__RECENTLY_MODIFIED:
            {
                query.AddViewColumn(WBColumn.WorkBoxDateLastModified);
                //query.AddViewColumn(WBColumn.RecordsType);
                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastModified, HorizontalAlign.Center, sortColumn, ascending));
                //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending));

                break;
            }

            case VIEW__RECENTLY_VISITED:
            {
                query.AddViewColumn(WBColumn.WorkBoxDateLastVisited);
                //query.AddViewColumn(WBColumn.RecordsType);
                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastVisited, HorizontalAlign.Center, sortColumn, ascending));
                //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending));

                break;
            }

            case VIEW__SELECTED_RECORDS_TYPE:
            {
                query.AddViewColumn(WBColumn.ReferenceDate);

                SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending));

                break;
            }
            }

            SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending));


            WBRecordsType recordsType = null;
            WBTeam        team        = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web);

            if (team != null)
            {
                switch (SelectedInvolvementFilter)
                {
                case FILTER_INVOLVEMENT__OWNS:
                {
                    WBLogging.Debug("Adding a filter for OwningTeam");
                    query.AddEqualsFilter(WBColumn.OwningTeam, team);
                    break;
                }

                case FILTER_INVOLVEMENT__INVOLVED:
                {
                    WBLogging.Debug("Adding a filter for InvolvedTeams");
                    query.AddEqualsFilter(WBColumn.InvolvedTeams, team);
                    break;
                }

                case FILTER_INVOLVEMENT__VISITING:
                {
                    WBLogging.Debug("Adding a filter for VisitingTeams");
                    query.AddEqualsFilter(WBColumn.VisitingTeams, team);
                    break;
                }
                }
            }

            if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE)
            {
                if (SelectedRecordsTypeGUID != "")
                {
                    recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID));
                }
                else if (!IsPostBack && !String.IsNullOrEmpty(webPart.InitialRecordsType))
                {
                    string initialRecordsTypePath = webPart.InitialRecordsType.Replace(" / ", "/").Trim();
                    recordsType = recordsTypes.GetSelectedRecordsType(initialRecordsTypePath);
                }

                if (recordsType != null)
                {
                    String recordsTypePath = recordsType.FullPath;
                    //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1);
                    recordsTypePath = recordsTypePath.Replace("/", " / ");

                    SelectionTitle.Text       = recordsTypePath;
                    SelectionDescription.Text = recordsType.Description;

                    WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType);
                    recordsTypeClause.UseDescendants = false;
                    query.AddClause(recordsTypeClause);

                    string statusFilter = SelectedWorkBoxStatusFilter;
                    if (statusFilter != "All")
                    {
                        query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter);
                    }

                    try
                    {
                        using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl))
                        {
                            DataTable dataTable = collection.Query(query);

                            SelectedWorkBoxes.DataSource = dataTable;
                            SelectedWorkBoxes.DataBind();

                            if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team))
                            {
                                string createNewURL  = collection.GetUrlForNewDialog(recordsType, team);
                                string createNewText = recordsType.CreateNewWorkBoxText;

                                CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>";
                            }
                            else
                            {
                                CreateNewWorkBoxLink.Text = "";
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        SelectedWorkBoxes.DataSource = null;
                        SelectedWorkBoxes.DataBind();

                        SelectionDescription.Text = SelectionDescription.Text + "<p><em>(An exception occured when trying to query the work boxes for this records type!)</em></p>";
                        CreateNewWorkBoxLink.Text = "";

                        WBLogging.RecordsTypes.Unexpected("Exception occurred on a team site when trying to query the work boxes of records type: " + recordsTypePath, exception);
                    }
                }
                else
                {
                    WBUtils.logMessage("SelectedRecordsTypeGUID was empty");
                }
            }
            else
            {
                String cachedDetailsListUrl = WBFarm.Local.OpenWorkBoxesCachedDetailsListUrl;

                // OK so this is a general 'recent' query
                using (SPWeb cacheWeb = SPContext.Current.Site.OpenWeb(cachedDetailsListUrl))
                {
                    SPList cacheList = cacheWeb.GetList(cachedDetailsListUrl);

                    DataTable dataTable = cacheList.WBxGetDataTable(SPContext.Current.Site, query);

                    SelectedWorkBoxes.DataSource = dataTable;
                    SelectedWorkBoxes.DataBind();

                    CreateNewWorkBoxLink.Text = "";

                    SelectionTitle.Text       = SelectedWorkBoxView + " Work Boxes";
                    SelectionDescription.Text = "Select a category from left hand tree navigation to list work boxes of that type.";
                }
            }


            // OK so now to check that the right filters are highlighted:
            ViewRecentlyCreated.CssClass  = "";
            ViewRecentlyModified.CssClass = "";
            ViewRecentlyVisited.CssClass  = "";

            if (SelectedWorkBoxView == VIEW__RECENTLY_CREATED)
            {
                ViewRecentlyCreated.CssClass = "wbf-filter-selected";
            }
            if (SelectedWorkBoxView == VIEW__RECENTLY_MODIFIED)
            {
                ViewRecentlyModified.CssClass = "wbf-filter-selected";
            }
            if (SelectedWorkBoxView == VIEW__RECENTLY_VISITED)
            {
                ViewRecentlyVisited.CssClass = "wbf-filter-selected";
            }

            FilterByOwns.CssClass     = "";
            FilterByInvolved.CssClass = "";
            FilterByVisiting.CssClass = "";

            if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__OWNS)
            {
                FilterByOwns.CssClass = "wbf-filter-selected";
            }
            if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__INVOLVED)
            {
                FilterByInvolved.CssClass = "wbf-filter-selected";
            }
            if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__VISITING)
            {
                FilterByVisiting.CssClass = "wbf-filter-selected";
            }

            FilterOpenStatus.CssClass   = "";
            FilterClosedStatus.CssClass = "";
            FilterAllStatus.CssClass    = "";

            if (SelectedWorkBoxStatusFilter == "Open")
            {
                FilterOpenStatus.CssClass = "wbf-filter-selected";
            }
            if (SelectedWorkBoxStatusFilter == "Closed")
            {
                FilterClosedStatus.CssClass = "wbf-filter-selected";
            }
            if (SelectedWorkBoxStatusFilter == "All")
            {
                FilterAllStatus.CssClass = "wbf-filter-selected";
            }
        }