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) { NotSetupText = "(<i>This site doesn't appear to be a team site so this web part wont work here.</i>)"; return; } teamGUIDString = WBExtensions.WBxToString(Team.Id); string recordsTypesListUrl = Team.RecordsTypesListUrl; /* * For the moment this web part is just going to list all of the available records types so the following code is not needed * * 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"]; try { foreach (Term term in recordsTypesTaxonomy.TermSet.Terms) { WBRecordsType recordsClass = new WBRecordsType(recordsTypesTaxonomy, term); 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); } }
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); } } } } }