protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb  web  = SPContext.Current.Web;
            SPSite site = SPContext.Current.Site;

            WBTaxonomy recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);

            string teamGUIDString = "";

            Team = WBTeam.GetFromTeamSite(SPContext.Current);
            if (Team == null)
            {
                return;
            }

            teamGUIDString = WBExtensions.WBxToString(Team.Id);
            string recordsTypesListUrl = Team.RecordsTypesListUrl;

            if (recordsTypesListUrl == null || recordsTypesListUrl == "")
            {
                //recordsTypesListUrl = web.Url + "/Lists/Configure%20Teams%20Records%20Classes";
                NotSetupText = "(<i>The team has no records types list setup yet.</i>)";
                return;
            }

            string selectedRecordsTypeGUID = Request.QueryString["recordsTypeGUID"];

            using (SPWeb configWeb = site.OpenWeb(recordsTypesListUrl))
            {
                ConfigurationList = configWeb.GetList(recordsTypesListUrl);
                if (ConfigurationList != null)
                {
                    if (!ConfigurationList.Fields.ContainsField("Records Class"))
                    {
                        ConfigurationList = null;
                        NotSetupText      = "(<i>The configuration list " + recordsTypesListUrl + " has no 'Records Class' column.</i>)";
                    }
                }
                else
                {
                    NotSetupText = "(<i>The configuration list " + recordsTypesListUrl + " was not set up correctly or does not exist.</i>)";
                }

                if (ConfigurationList != null)
                {
                    RecordsTypeTreeView.Nodes.Clear();

                    foreach (SPListItem item in ConfigurationList.Items)
                    {
                        try
                        {
                            string groupName = item.WBxGetColumnAsString("Records Group");
                            if (groupName.Equals(RecordsGroup))
                            {
                                WBRecordsType recordsClass = new WBRecordsType(recordsTypesTaxonomy, WBExtensions.WBxGetColumnAsString(item, "Records Class"));

                                TreeNode node = createNodes(recordsClass);

                                RecordsTypeTreeView.Nodes.Add(node);

                                RecordsTypeTreeView.CollapseAll();

                                expandByRecordsTypeGUID(RecordsTypeTreeView.Nodes, selectedRecordsTypeGUID);
                            }
                        }
                        catch (Exception exception)
                        {
                            WBUtils.logMessage("The error message was: " + exception.Message);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb  web  = SPContext.Current.Web;
            SPSite site = SPContext.Current.Site;

            string selectedToggleID        = Request.Params["selectedToggleID"];
            string selectedRecordsTypeGUID = Request.Params["recordsTypeGUID"];

            WBTaxonomy recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);

            string teamGUIDString = "";

            Team = WBTeam.GetFromTeamSite(SPContext.Current);
            if (Team == null)
            {
                return;
            }

            teamGUIDString = WBExtensions.WBxToString(Team.Id);
            string recordsTypesListUrl = Team.RecordsTypesListUrl;

            if (recordsTypesListUrl == null || recordsTypesListUrl == "")
            {
                // recordsTypesListUrl = web.Url + "/Lists/Configure%20Teams%20Records%20Classes";
                NotSetupText = "(<i>The team has no records types list setup yet.</i>)";
                return;
            }

            using (SPWeb configWeb = site.OpenWeb(recordsTypesListUrl))
            {
                ConfigurationList = configWeb.GetList(recordsTypesListUrl);
                if (ConfigurationList != null)
                {
                    if (!ConfigurationList.Fields.ContainsField("Records Class"))
                    {
                        ConfigurationList = null;
                        NotSetupText      = "(<i>The configuration list " + recordsTypesListUrl + " has no 'Records Class' column.</i>)";
                    }
                }
                else
                {
                    NotSetupText = "(<i>The configuration list " + recordsTypesListUrl + " was not set up correctly or does not exist.</i>)";
                }

                if (ConfigurationList != null)
                {
                    RecordsClasses = new List <Hashtable>();

                    int classCount = 0;
                    int classTotal = 0;

                    foreach (SPListItem item in ConfigurationList.Items)
                    {
                        try
                        {
                            string groupName = item.WBxGetColumnAsString("Records Group");
                            if (groupName.Equals(RecordsGroup))
                            {
                                classTotal++;
                            }
                        }
                        catch (Exception exception)
                        {
                            WBUtils.logMessage("The error message when counting the classes was: " + exception.StackTrace);
                        }
                    }

                    WBUtils.logMessage("The class count was found to be: " + classCount);


                    foreach (SPListItem item in ConfigurationList.Items)
                    {
                        try
                        {
                            string groupName = item.WBxGetColumnAsString("Records Group");
                            if (groupName.Equals(RecordsGroup))
                            {
                                classCount++;

                                Hashtable recordsClassDetails = new Hashtable();

                                List <Hashtable> recordsTypes = new List <Hashtable>();

                                WBRecordsType recordsClass = new WBRecordsType(recordsTypesTaxonomy, WBExtensions.WBxGetColumnAsString(item, "Records Class"));


                                string workBoxCollectionURL = recordsClass.WorkBoxCollectionUrl;
                                string viewPagerelativeURL  = WBExtensions.WBxGetColumnAsString(item, "ViewPageRelativeURL");
                                string recordsTypeGUID      = recordsClass.Id.WBxToString();
                                string uniqueToggleID       = string.Format("WBF_Grouping_{0}_Child_{1}", AdditionalCSSStyle, classCount);

                                string viewURL = "#";

                                if (viewPagerelativeURL != "")
                                {
                                    viewURL = string.Format("{0}{1}?selectedToggleID={2}&recordsTypeGUID={3}&workBoxCollectionURL={4}",
                                                            SPContext.Current.Web.ServerRelativeUrl,
                                                            viewPagerelativeURL,
                                                            uniqueToggleID,
                                                            recordsTypeGUID,
                                                            Uri.EscapeDataString(workBoxCollectionURL));
                                }

                                /*
                                 * string viewURL = string.Format("{0}{1}?selectedToggleID={2}",
                                 *  SPContext.Current.Web.ServerRelativeUrl,
                                 *  viewPagerelativeURL,
                                 *  uniqueToggleID);
                                 */


                                string selectedRecordsClass = "";
                                if (uniqueToggleID.Equals(selectedToggleID))
                                {
                                    selectedRecordsClass = " wbf-selected-records-class";
                                }

                                string selectedRecordsType = "";
                                if (recordsTypeGUID.Equals(selectedRecordsTypeGUID))
                                {
                                    selectedRecordsType = " wbf-selected-records-type";
                                }

                                WBUtils.logMessage("Class count and class total: " + classCount + "  " + classTotal);
                                if (classCount == classTotal)
                                {
                                    selectedRecordsClass += " wbf-last-class";
                                }


                                recordsClassDetails[LINK_TEXT]                = recordsClass.Name;
                                recordsClassDetails[LINK_URL]                 = viewURL;
                                recordsClassDetails[ON_CLICK_COMMAND]         = "javascript: $('#" + uniqueToggleID + "').toggle(200);";
                                recordsClassDetails[UNIQUE_TOGGLE_ID]         = uniqueToggleID;
                                recordsClassDetails[SELECTED_CLASS_CSS_STYLE] = selectedRecordsClass;
                                recordsClassDetails[SELECTED_TYPE_CSS_STYLE]  = selectedRecordsType;

                                int typeCount = 0;
                                int typeTotal = recordsClass.Term.Terms.Count;

                                Dictionary <String, Hashtable> allRecordsTypeDetails = new Dictionary <String, Hashtable>();

                                foreach (Term term in recordsClass.Term.Terms)
                                {
                                    typeCount++;
                                    Hashtable     recordsTypeDetails = new Hashtable();
                                    WBRecordsType recordsType        = new WBRecordsType(recordsTypesTaxonomy, term);

                                    // If the term has been marked as unavailable then it shouldn't be liseted here.
                                    if (!recordsType.IsAvailableForTagging || !recordsType.AllowWorkBoxRecords)
                                    {
                                        continue;
                                    }

                                    recordsTypeGUID = recordsType.Id.ToString();

                                    selectedRecordsType = "";
                                    if (recordsTypeGUID.Equals(selectedRecordsTypeGUID))
                                    {
                                        selectedRecordsType = " wbf-selected-records-type";
                                    }

                                    viewURL = string.Format("{0}{1}?selectedToggleID={2}&recordsTypeGUID={3}&workBoxCollectionURL={4}",
                                                            SPContext.Current.Web.ServerRelativeUrl,
                                                            viewPagerelativeURL,
                                                            uniqueToggleID,
                                                            recordsTypeGUID,
                                                            Uri.EscapeDataString(workBoxCollectionURL));

                                    if (typeCount == typeTotal)
                                    {
                                        selectedRecordsType += " wbf-last-type";
                                    }

                                    recordsTypeDetails[LINK_TEXT]               = recordsType.Name;
                                    recordsTypeDetails[LINK_URL]                = viewURL;
                                    recordsTypeDetails[ON_CLICK_COMMAND]        = "";
                                    recordsTypeDetails[SELECTED_TYPE_CSS_STYLE] = selectedRecordsType;


                                    allRecordsTypeDetails.Add(recordsType.Name, recordsTypeDetails);
                                }

                                List <String> allNames = new List <String>(allRecordsTypeDetails.Keys);
                                allNames.Sort();

                                foreach (String name in allNames)
                                {
                                    recordsTypes.Add(allRecordsTypeDetails[name]);
                                }

                                /* Not showing the create link here any more.
                                 * string createNewURL = "";
                                 * string createNewText = "";
                                 * WBCollection collection = null;
                                 *
                                 * if (workBoxCollectionURL != null && workBoxCollectionURL != "")
                                 * {
                                 *  collection = new WBCollection(workBoxCollectionURL);
                                 *  if (collection.CanAnyoneCreate == true)
                                 *  {
                                 *      createNewURL = collection.GetUrlForNewDialog(Team);
                                 *      createNewText = collection.CreateNewWorkBoxText;
                                 *  }
                                 * }
                                 * else
                                 * {
                                 *  createNewText = "";
                                 *  createNewURL = "";
                                 *  workBoxCollectionURL = "";
                                 * }
                                 *
                                 * if (createNewText != "")
                                 * {
                                 *  Hashtable createLink = new Hashtable();
                                 *
                                 *  createLink[LINK_TEXT] = createNewText;
                                 *  createLink[LINK_URL] = "#";
                                 *  createLink[ON_CLICK_COMMAND] = "javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500);";
                                 *  createLink[ADDITIONAL_TYPE_CSS_STYLE] = "wbf-create-new-link";
                                 *
                                 *  recordsTypes.Add(createLink);
                                 * }
                                 */

                                recordsClassDetails[RECORDS_TYPES] = recordsTypes;

                                RecordsClasses.Add(recordsClassDetails);
                            }
                        }
                        catch (Exception exception)
                        {
                            RecordsClasses.Add(makeErrorRecordsClassEntry());
                            WBUtils.logMessage("The error message was: " + exception.StackTrace);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            webPart = this.Parent as WorkBoxExplorer;

            SPWebPartManager webPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page);

            if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) ||
                (webPartManager.DisplayMode == WebPartManager.EditDisplayMode))
            {
                InEditMode = true;
            }

            SearchScope = WBUtils.UrlDataEncode(webPart.SearchScope);

            SelectedWorkBoxes.AllowSorting = true;
            SelectedWorkBoxes.Sorting     += new GridViewSortEventHandler(SelectedWorkBoxes_Sorting);

            SelectedWorkBoxes.AllowPaging                   = true;
            SelectedWorkBoxes.PageIndexChanging            += new GridViewPageEventHandler(SelectedWorkBoxes_PageIndexChanging);
            SelectedWorkBoxes.PagerSettings.Mode            = PagerButtons.Numeric;
            SelectedWorkBoxes.PagerSettings.Position        = PagerPosition.Bottom;
            SelectedWorkBoxes.PagerSettings.PageButtonCount = 50;
            SelectedWorkBoxes.PagerSettings.Visible         = true;
            SelectedWorkBoxes.PageSize = 30;

            // this odd statement is required in order to get the pagination to work with an SPGridView!
            SelectedWorkBoxes.PagerTemplate = null;

            CoreResultsWebPart.UseLocationVisualization = false;
            CoreResultsWebPart.PropertiesToRetrieve     = string.Empty;
            CoreResultsWebPart.SelectColumns            = @"<Columns>  <Column Name=""WorkId""/>  <Column Name=""Rank""/>  <Column Name=""Title""/>  <Column Name=""Author""/>  <Column Name=""Size""/>  <Column Name=""Path""/>  <Column Name=""Description""/>  <Column Name=""Write""/>  <Column Name=""SiteName""/>  <Column Name=""CollapsingStatus""/>  <Column Name=""HitHighlightedSummary""/>  <Column Name=""HitHighlightedProperties""/>  <Column Name=""ContentClass""/>  <Column Name=""IsDocument""/>  <Column Name=""PictureThumbnailURL""/>  <Column Name=""PopularSocialTags""/>  <Column Name=""PictureWidth""/>  <Column Name=""PictureHeight""/>  <Column Name=""DatePictureTaken""/>  <Column Name=""ServerRedirectedURL""/>  <Column Name=""SiteTitle""/>  <Column Name=""SPWebURL""/>  <Column Name=""OwningTeam""/>  </Columns>";
            CoreResultsWebPart.XslLink = "/Style Library/WBF/wb-explorer-search-results.xslt";

            //CoreResultsWebPart.DisplayAlertMeLink = true;
            //CoreResultsWebPart.AllowConnect = false;


            SPWeb  web  = SPContext.Current.Web;
            SPSite site = SPContext.Current.Site;

            WBTaxonomy recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);

            string teamGUIDString = "";

            Team = WBTeam.GetFromTeamSite(SPContext.Current);
            if (Team == null)
            {
                return;
            }

            if (Team.IsCurrentUserTeamOwnerOrSystemAdmin())
            {
                canSaveDefaultView = true;
            }

            // RefinementByOwningTeam = "owningteam%3D%22%23" + (Team.Id.ToString().Replace(" ", "%20").Replace("#", "%23").Replace("-", "%2D")) + "%22";
            // RefinementByOwningTeam = "owningteam%3D%22" + (Team.Name.ToString().Replace(" ", "%20").Replace("#", "%23").Replace("-", "%2D")) + "%22";
            RefinementByOwningTeam = WBUtils.UrlDataEncode("owningteam=\"" + Team.Name + "\"");

            teamGUIDString = WBExtensions.WBxToString(Team.Id);
            string recordsTypesListUrl = Team.RecordsTypesListUrl;

            if (recordsTypesListUrl == null || recordsTypesListUrl == "")
            {
                //recordsTypesListUrl = web.Url + "/Lists/Configure%20Teams%20Records%20Classes";
                NotSetupText = "(<i>The team has no records types list setup yet.</i>)";
                return;
            }

            // urm ... this is a real mess - a hidden field and a view state - it's a mashup mess!!
            String selectedRecordsTypeGUID = Request.QueryString["recordsTypeGUID"];

            if (String.IsNullOrEmpty(selectedRecordsTypeGUID))
            {
                String guidString = HiddenRecordsTypeGUIDField.Value;
                if (guidString != null && guidString != "")
                {
                    SelectedRecordsTypeGUID = guidString;
                }
            }
            else
            {
                SelectedRecordsTypeGUID          = selectedRecordsTypeGUID;
                HiddenRecordsTypeGUIDField.Value = selectedRecordsTypeGUID;
            }



            using (SPWeb configWeb = site.OpenWeb(recordsTypesListUrl))
            {
                ConfigurationList = configWeb.GetList(recordsTypesListUrl);
                if (ConfigurationList != null)
                {
                    if (!ConfigurationList.Fields.ContainsField("Records Class"))
                    {
                        ConfigurationList = null;
                        NotSetupText      = "(<i>The configuration list " + recordsTypesListUrl + " has no 'Records Class' column.</i>)";
                    }
                }
                else
                {
                    NotSetupText = "(<i>The configuration list " + recordsTypesListUrl + " was not set up correctly or does not exist.</i>)";
                }

                if (ConfigurationList != null)
                {
                    TeamAdminRecordsTypesTreeView.Nodes.Clear();
                    OurWorkRecordsTypesTreeView.Nodes.Clear();
                    CouncilWideRecordsTypesTreeView.Nodes.Clear();

                    TeamAdminRecordsTypesFilter.Nodes.Clear();
                    OurWorkRecordsTypesFilter.Nodes.Clear();
                    CouncilWideRecordsTypesFilter.Nodes.Clear();

                    foreach (SPListItem item in ConfigurationList.Items)
                    {
                        try
                        {
                            WBRecordsType recordsClass      = new WBRecordsType(recordsTypesTaxonomy, WBExtensions.WBxGetColumnAsString(item, "Records Class"));
                            TreeNode      createNewNodes    = createNodes(recordsClass, Team, false);
                            TreeNode      forFilteringNodes = createNodes(recordsClass, Team, true);

                            string groupName = item.WBxGetColumnAsString("Records Group");
                            if (groupName.Equals("Team admin"))
                            {
                                addNodesToTreeView(TeamAdminRecordsTypesTreeView, createNewNodes, selectedRecordsTypeGUID);
                                addNodesToTreeView(TeamAdminRecordsTypesFilter, forFilteringNodes, selectedRecordsTypeGUID);
                            }

                            if (groupName.Equals("Our work"))
                            {
                                addNodesToTreeView(OurWorkRecordsTypesTreeView, createNewNodes, selectedRecordsTypeGUID);
                                addNodesToTreeView(OurWorkRecordsTypesFilter, forFilteringNodes, selectedRecordsTypeGUID);
                            }

                            if (groupName.Equals("Council-wide business"))
                            {
                                addNodesToTreeView(CouncilWideRecordsTypesTreeView, createNewNodes, selectedRecordsTypeGUID);
                                addNodesToTreeView(CouncilWideRecordsTypesFilter, forFilteringNodes, selectedRecordsTypeGUID);
                            }
                        }
                        catch (Exception exception)
                        {
                            WBUtils.logMessage("The error message was: " + exception.Message);
                        }
                    }
                }
            }


            if (!IsPostBack)
            {
                List <String> ascendingDescendingOptions = new List <String>();
                ascendingDescendingOptions.Add("Ascending");
                ascendingDescendingOptions.Add("Descending");

                AscendingDescendingChoice.DataSource = ascendingDescendingOptions;
                AscendingDescendingChoice.DataBind();

                List <String> statusOptions = new List <String>();
                statusOptions.Add("Open");
                statusOptions.Add("Closed");
                statusOptions.Add("Deleted");
                statusOptions.Add("Any");

                StatusFilter.DataSource = statusOptions;
                StatusFilter.DataBind();


                List <String> involvementOptions = new List <String>();
                involvementOptions.Add(FILTER_INVOLVEMENT__OWNS);
                involvementOptions.Add(FILTER_INVOLVEMENT__INVOLVED);
                involvementOptions.Add(FILTER_INVOLVEMENT__VISITING);

                InvolvementFilter.DataSource = involvementOptions;
                InvolvementFilter.DataBind();

                if (!LoadDefaultView())
                {
                    SetSortColumn(WBColumn.WorkBoxDateLastModified);
                    GridViewSortDirection        = SortDirection.Descending;
                    SelectedViewStyle            = VIEW_STYLE__ICONS;
                    StatusCheckBox.Checked       = false;
                    RecordsTypeCheckBox.Checked  = true;
                    LastModifiedCheckBox.Checked = true;
                    DateCreatedCheckBox.Checked  = true;

                    StatusFilter.WBxSafeSetSelectedValue("Any");
                }


                WBLogging.Debug("Not in post back so setting guid value to be: " + SelectedRecordsTypeGUID);
                RefreshBoundData();
            }
        }