/// <summary> /// //当页面初始化完成时,加载页面去持的显示模式到DropDownList控件中,并初始化个性化选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitComplete(object sender, System.EventArgs e) { //获取当前页面上的WebPartManager对象实例 _manager = WebPartManager.GetCurrentWebPartManager(Page); //获取浏览模式的名称 String browseModeName = WebPartManager.BrowseDisplayMode.Name; ////遍历页面上所有可用的显示模式的集合,添加到DropDownList控件中 foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes) { String modeName = mode.Name; // 添加前确保该模式允许添加 if (mode.IsEnabled(_manager)) { ListItem item = new ListItem(modeName, modeName); DisplayModeDropdown.Items.Add(item); } } //----------------------------------------------------------------------------- //如果该用户被指定为共享范围,则显示配置面板,为当前用户选择合相应的用户范围 //否则隐藏配置面板。 if (_manager.Personalization.CanEnterSharedScope) { Panel2.Visible = true; if (_manager.Personalization.Scope == PersonalizationScope.User) RadioButton1.Checked = true; else RadioButton2.Checked = true; } }
void InitComplete(object sender, System.EventArgs e) { manager = WebPartManager.GetCurrentWebPartManager(Page); String browseModeName = WebPartManager.BrowseDisplayMode.Name; foreach (WebPartDisplayMode mode in manager.SupportedDisplayModes) { String modeName = mode.Name; if (mode.IsEnabled(manager)) { ListItem item = new ListItem(modeName, modeName); DisplayModeDropdown.Items.Add(item); } } }
public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IEnumerable registry, IBinder binder, WebPartManager manager) { throw new NotImplementedException(); }
protected override void SavePersonalizationBlob(WebPartManager webPartManager, string path, string userName, byte[] dataBlob) { SaveBlob(path, dataBlob); }
public virtual void ResetPersonalizationState(WebPartManager webPartManager) { }
public virtual System.Collections.IDictionary DetermineUserCapabilities(WebPartManager webPartManager) { }
public static void SetPersonalizationFromXml(HttpContext context, Page pageNode, XmlDocument xml, out string errorMessage) { string error = String.Empty; string virtualPath = CreateVirtualPath(pageNode.Path); PageBase page = InstantiatePage(context, virtualPath, pageNode); page.PreLoad += delegate { WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(page); WebPartZoneCollection webPartZones = wpm.Zones; foreach (WebPartZone zone in webPartZones) { foreach (WebPart part in zone.WebParts) { if (!part.IsStatic) { wpm.DeleteWebPart(part); } } XmlNode zoneDescriptionNode = xml.SelectNodes(@"//*[@id='" + zone.ID + "']")[0]; XmlElement zoneDescription = zoneDescriptionNode as XmlElement; if (zoneDescription != null) { foreach (XmlElement webPartDescription in zoneDescription.GetElementsByTagName("webPart")) { string webPartXml = String.Empty; using (StringWriter sw = new StringWriter()) { using (XmlWriter writer = new XmlTextWriter(sw)) { writer.WriteStartElement("webParts"); webPartDescription.WriteTo(writer); writer.WriteEndElement(); writer.Flush(); } webPartXml = sw.ToString(); } using (StringReader sr = new StringReader(webPartXml)) { using (XmlReader reader = new XmlTextReader(sr)) { WebPart part = wpm.ImportWebPart(reader, out error); wpm.AddWebPart(part, zone, zone.WebParts.Count); } } } } } }; //TODO: Clever exception handling ExecutePage(context, virtualPath, page, pageNode, true); errorMessage = error; }
// Methods public virtual bool IsEnabled(WebPartManager webPartManager) { }
public static void GetFilterInfo(IDictionary inst, string schemaName, ref string clickScript, System.Web.UI.WebControls.WebParts.WebPart webPart, Page page, ref bool includeFilters, ref string fj, ref List <KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > > effectiveFilters) { SPWebPartManager currentWebPartManager = null; System.Web.UI.WebControls.WebParts.WebPart part = null; IList list = null; List <string> list2 = new List <string>(); List <object[]> list3 = new List <object[]>(); includeFilters = false; string filterCaml = ""; if (inst["filter"] != null) { try { includeFilters = (bool)inst["filter"]; } catch { includeFilters = false; } } if (includeFilters && !IsLic(2)) { includeFilters = false; clickScript = "alert('" + SPEncode.ScriptEncode(ProductPage.GetResource("NopeEd", new object[] { ProductPage.GetProductResource("PC_" + schemaName + "_filter", new object[0]), "Basic" })) + "');"; } if (includeFilters && (effectiveFilters == null)) { effectiveFilters = new List <KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > >(); try { currentWebPartManager = WebPartManager.GetCurrentWebPartManager(page) as SPWebPartManager; } catch { } if ((webPart != null) && (currentWebPartManager != null)) { foreach (System.Web.UI.WebControls.WebParts.WebPart part2 in ProductPage.TryEach <System.Web.UI.WebControls.WebParts.WebPart>(currentWebPartManager.WebParts)) { if (part2.GetType().AssemblyQualifiedName == "roxority_FilterZen.roxority_FilterWebPart, roxority_FilterZen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a2103dd0c3e898e1") { foreach (System.Web.UI.WebControls.WebParts.WebPart part3 in ((getConnPartMethod == null) ? (getConnPartMethod = part2.GetType().GetMethod("GetConnectedParts", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, System.Type.EmptyTypes, null)) : getConnPartMethod).Invoke(part2, null) as IEnumerable <System.Web.UI.WebControls.WebParts.WebPart> ) { if (part3.ID.Equals(webPart.ID)) { part = part2; break; } } } if (part != null) { break; } } } if (part != null) { try { if (!((bool)part.GetType().GetMethod("LicEd", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(part, new object[] { 2 }))) { clickScript = "alert('" + SPEncode.ScriptEncode(ProductPage.GetProductResource("Old_NoFilterZenEnt", new object[0])) + "');"; part = null; } } catch { clickScript = "alert('" + SPEncode.ScriptEncode(ProductPage.GetProductResource("Old_NoFilterZenEnt", new object[0])) + "');"; part = null; } } fj = string.Empty; if (part != null) { try { filterCaml = ((roxority_FilterZen.roxority_FilterWebPart)(part)).GeneratedQuery; list = ((partFiltersProp == null) ? (partFiltersProp = part.GetType().GetProperty("PartFilters", BindingFlags.Public | BindingFlags.Instance)) : partFiltersProp).GetValue(part, null) as IList; fj = ((partJsonProp == null) ? (partJsonProp = part.GetType().GetProperty("JsonFilters", BindingFlags.Public | BindingFlags.Instance)) : partJsonProp).GetValue(part, null) as string; list2.AddRange(((string)((camlAndProp == null) ? (camlAndProp = part.GetType().GetProperty("CamlFiltersAndCombined", BindingFlags.Public | BindingFlags.Instance)) : camlAndProp).GetValue(part, null)).Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); } catch { } if (list != null) { foreach (object obj3 in list) { if (kvpValProp == null) { kvpValProp = obj3.GetType().GetProperty("Value", BindingFlags.Public | BindingFlags.Instance); } object obj2 = kvpValProp.GetValue(obj3, null); if (obj2 != null) { if (fpKeyProp == null) { fpKeyProp = obj2.GetType().GetProperty("Key", BindingFlags.Public | BindingFlags.Instance); } if (fpValProp == null) { fpValProp = obj2.GetType().GetProperty("Value", BindingFlags.Public | BindingFlags.Instance); } if (fpOpProp == null) { fpOpProp = obj2.GetType().GetProperty("CamlOperator", BindingFlags.Public | BindingFlags.Instance); } list3.Add(new object[] { fpKeyProp.GetValue(obj2, null), fpValProp.GetValue(obj2, null), (CamlOperator)Enum.Parse(typeof(CamlOperator), fpOpProp.GetValue(obj2, null).ToString(), true) }); } } } foreach (object[] objArray in list3) { int num2; KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > item = new KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> >(objArray[0] as string, new KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool>(new List <KeyValuePair <string, CamlOperator> >(), list2.Contains(objArray[0] as string))); int num = num2 = -1; foreach (KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > pair2 in effectiveFilters) { num2++; if (pair2.Key == item.Key) { num = num2; item = pair2; break; } } item.Value.Key.Add(new KeyValuePair <string, CamlOperator>(objArray[1] as string, (CamlOperator)objArray[2])); if (num >= 0) { effectiveFilters[num] = item; } else { effectiveFilters.Add(item); } } } } fj += "((((((" + filterCaml + "))))))"; }
protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as PickedDocumentsGroup; SPWebPartManager webPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page); Guid WebPartGuid = webPartManager.GetStorageKey(webPart); WebPartUniqueID = WebPartGuid.ToString().Replace("-", String.Empty);; //EditRelatedDocumentsButton.OnClientClick = "WorkBoxFramework_editRelatedDocuments(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + webPart.PickedDocumentsDetails + "\"); return false;"; String[] detailsToSave = new String[5]; detailsToSave[0] = WBUtils.ReplaceDelimiterCharacters(webPart.Title); detailsToSave[1] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupDescription); detailsToSave[2] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupSubjectTags); detailsToSave[3] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupCoverage); detailsToSave[4] = WBUtils.ReplaceDelimiterCharacters(webPart.PickedDocumentsDetails.WBxTrim()); String currentDetails = String.Join(",", detailsToSave); WBLogging.Debug("Current details: " + currentDetails); if (IsPostBack) { if (NeedToSave.Value == "true") { WBLogging.Debug("Trying to save value: " + NewDocumentsGroupDetails.Value); string[] newDetails = NewDocumentsGroupDetails.Value.WBxTrim().Split(','); if (newDetails.Length != 5) { WBLogging.Debug("The details sent to this page have the wrong structure: " + NewDocumentsGroupDetails.Value); Description.Text = "(the web part has not yet been edited)."; return; } webPart.Title = WBUtils.PutBackDelimiterCharacters(newDetails[0]); webPart.DocumentsGroupDescription = WBUtils.PutBackDelimiterCharacters(newDetails[1]); webPart.DocumentsGroupSubjectTags = WBUtils.PutBackDelimiterCharacters(newDetails[2]); webPart.DocumentsGroupCoverage = WBUtils.PutBackDelimiterCharacters(newDetails[3]); webPart.PickedDocumentsDetails = WBUtils.PutBackDelimiterCharacters(newDetails[4]); webPartManager.SaveChanges(WebPartGuid); SPContext.Current.File.Update(); SPContext.Current.Web.Update(); currentDetails = NewDocumentsGroupDetails.Value.WBxTrim(); WBLogging.Debug("New current details: " + currentDetails); } } if (!String.IsNullOrEmpty(currentDetails) && !currentDetails.Contains(",")) { WBLogging.Generic.Unexpected("The PickRelatedDocuments web part had an odd value: " + currentDetails); currentDetails = ""; } if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) || (webPartManager.DisplayMode == WebPartManager.EditDisplayMode)) { EditPanel.Visible = true; InEditMode = true; EditDocumentsGroupButton.OnClientClick = "WorkBoxFramework_editDocumentsGroup(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + currentDetails + "\"); return false;"; } else { EditPanel.Visible = false; EditDocumentsGroupButton.OnClientClick = ""; } WBLogging.Debug("PickedDocumentsGroup currentDetails: " + currentDetails); Title.Text = webPart.Title; Description.Text = WBUtils.MaybeAddParagraphTags(webPart.DocumentsGroupDescription); WBTermCollection <WBTerm> allSubjects = new WBTermCollection <WBTerm>(null, webPart.DocumentsGroupSubjectTags); SubjectTags.Text = allSubjects.Names(); Coverage.Text = webPart.DocumentsGroupCoverage; if (String.IsNullOrEmpty(webPart.PickedDocumentsDetails)) { DocumentsList.Text = "<ul><li>(No documents picked)</li></ul>"; DocumentsToView = false; return; } String extranetRecordsLibraryURL = WBFWebPartsUtils.GetExtranetLibraryURL(SPContext.Current.Site); SPSite extranetRecordsSite = null; SPWeb extranetRecordsWeb = null; SPList extranetRecordsLibrary = null; try { string[] documentsDetailsArray = webPart.PickedDocumentsDetails.Split(';'); String publicRecordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite publicRecordsSite = new SPSite(publicRecordsLibraryURL)) using (SPWeb publicRecordsWeb = publicRecordsSite.OpenWeb()) { SPList publicRecordsLibrary = publicRecordsWeb.GetList(publicRecordsLibraryURL); String html = "<ul>\n"; foreach (string documentDetails in documentsDetailsArray) { string[] documentDetailsArray = documentDetails.Split('|'); if (documentDetailsArray.Length != 4) { WBLogging.Generic.Unexpected("Badly formatted document details in PickRelatedDocuments web part: " + currentDetails + " - Ignoring these details"); continue; } string zone = documentDetailsArray[0]; string recordID = documentDetailsArray[1]; string sourceID = documentDetailsArray[2]; string filename = documentDetailsArray[3]; SPListItem item = null; if (zone == "Public Extranet") { if (extranetRecordsLibrary == null) { extranetRecordsSite = new SPSite(extranetRecordsLibraryURL); extranetRecordsWeb = extranetRecordsSite.OpenWeb(); extranetRecordsLibrary = extranetRecordsWeb.GetList(extranetRecordsLibraryURL); } item = WBFWebPartsUtils.GetRecord(extranetRecordsSite, extranetRecordsWeb, extranetRecordsLibrary, zone, recordID); } else { item = WBFWebPartsUtils.GetRecord(publicRecordsSite, publicRecordsWeb, publicRecordsLibrary, zone, recordID); } if (item == null) { if (InEditMode) { html += "<li><i>(Could not find document)</i></li>"; } } else { DocumentsToView = true; string title = item.WBxGetAsString(WBColumn.Title); if (String.IsNullOrEmpty(title)) { title = Path.GetFileNameWithoutExtension(item.Name); } string extension = Path.GetExtension(item.Name).Replace(".", "").ToUpper(); string additionalText = ""; long fileLength = (item.File.Length / 1024); additionalText = ", " + fileLength + "KB"; if (item.WBxHasValue(WBColumn.ReferenceDate)) { DateTime referenceDate = (DateTime)item.WBxGet(WBColumn.ReferenceDate); string referenceDateString = string.Format("{0}-{1}-{2}", referenceDate.Year.ToString("D4"), referenceDate.Month.ToString("D2"), referenceDate.Day.ToString("D2")); additionalText += ", " + referenceDateString; } html += String.Format("<li><img src=\"{0}\" alt=\"{1}\"/><a target=\"_blank\" href=\"{2}\">{1}</a> <span>({3})</span></li>", WBUtils.DocumentIcon16(item.WBxGetAsString(WBColumn.Name)), title, item.WBxGetAsString(WBColumn.EncodedAbsoluteURL), extension + additionalText); } } html += "</ul>\n"; DocumentsList.Text = html; } } catch (Exception exception) { if (InEditMode) { DocumentsList.Text = "An error occurred: " + exception.Message; } else { DocumentsToView = false; } } finally { if (extranetRecordsWeb != null) { extranetRecordsWeb.Dispose(); } if (extranetRecordsSite != null) { extranetRecordsSite.Dispose(); } } }
public SNWebPartPersonalization(WebPartManager parent) : base(parent) { }
public DictionaryPersonalizationState(WebPartManager manager) : base(manager) { this.States = new Dictionary <string, PersonalizationDictionary>(); }
public override IResult Parse(object source) { WorkFlowManagerWebPart workflowManagerWebPart = source as WorkFlowManagerWebPart; if (null == workflowManagerWebPart) { throw new ArgumentException("source is not a WorkFlowManagerWebPart"); } IConfiguration configuration = workflowManagerWebPart.Configuration; if (null == configuration) { throw new ArgumentException("source does not have a configuration"); } WebPartManager Manager = WebPartManager.GetCurrentWebPartManager(workflowManagerWebPart.Page); if (configuration.Sections.ContainsKey("flows")) { WorkFlow.WorkFlow flow = new WorkFlow.WorkFlow(); flow.Monitor = workflowManagerWebPart.Monitor; flow.Title = "screen flow"; IConfigurationSection flowsSection = configuration.GetConfigurationSectionReference("flows"); foreach (IConfigurationElement flowElement in flowsSection.Elements.Values) { Job job = new Job(); job.Monitor = workflowManagerWebPart.Monitor; job.Title = flowElement.ConfigKey; if (flowElement.Elements.ContainsKey("conditions")) { foreach (IConfigurationElement conditionElement in flowElement.Elements["conditions"].Elements.Values) { if (flowElement.Elements["conditions"].Attributes.ContainsKey("type")) { ReflectionServices.SetValue(job.Conditions, "Type", flowElement.Elements["conditions"].GetAttributeReference("type").Value.ToString()); } if (conditionElement.Attributes.ContainsKey("waitfor") && !("waitfor" == conditionElement.GetAttributeReference("type").Value.ToString())) { throw new InvalidOperationException("Unknown condition type " + conditionElement.GetAttributeReference("type").Value.ToString()); } WaitForCondition condition = new WaitForCondition(); condition.Monitor = workflowManagerWebPart.Monitor; if (conditionElement.Attributes.ContainsKey("milestone")) { condition.Milestone = conditionElement.GetAttributeReference("milestone").Value.ToString(); } if (conditionElement.Attributes.ContainsKey("sender")) { condition.Chronicler = (ReflectionServices.FindControlEx(conditionElement.GetAttributeReference("sender").Value.ToString(), Manager) as IChronicler); } condition.Target = job; job.Conditions.Add(condition); if (conditionElement.Elements.ContainsKey("expression")) { IConfigurationElement expressionElement = conditionElement.GetElementReference("expression"); IExpression expression = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression; if (null != expression) { expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager); condition.Expression = expression; } } } } if (flowElement.Elements.ContainsKey("transits")) { foreach (IConfigurationElement transitElement in flowElement.GetElementReference("transits").Elements.Values) { if (transitElement.Attributes.ContainsKey("key")) { Transit transit = new Transit(); transit.Monitor = workflowManagerWebPart.Monitor; transit.Title = transitElement.ConfigKey; transit.Key = transitElement.GetAttributeReference("key").Value.ToString(); transit.Storage = workflowManagerWebPart.StatePersistence; if (transitElement.Elements.ContainsKey("expression")) { IConfigurationElement expressionElement = transitElement.GetElementReference("expression"); IExpression expression = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression; if (null == expression) { throw new InvalidOperationException("Token is not an IExpression"); } expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager); transit.Expression = expression; } if (transitElement.Elements.ContainsKey("source")) { transit.Source = this.CreateTransitPoint(Manager, transitElement.GetElementReference("source"), workflowManagerWebPart.ExpressionsManager); } if (transitElement.Elements.ContainsKey("destination")) { transit.Destination = this.CreateTransitPoint(Manager, transitElement.GetElementReference("destination"), workflowManagerWebPart.ExpressionsManager); } if (transitElement.Attributes.ContainsKey("persistent")) { transit.IsPersistent = bool.Parse(transitElement.GetAttributeReference("persistent").Value.ToString()); } job.Transits.Add(transit); } } } flow.Jobs.Add(job); } workflowManagerWebPart.WorkFlows.Add(flow); } return(null); }
public SNWebPartChrome(WebPartZoneBase zone, WebPartManager manager) : base(zone, manager) { }
public virtual void Extract(Control container, IConfigurationType config, IEnumerable registry, WebPartManager manager) { throw new NotImplementedException(); }
public virtual void DisplayItem(Table table, IConfigurationElement element, string index, IBinder binder, ITemplatingItem item, TableItemStyle style, TableItemStyle invalidStyle, WebPartManager manager) { this.DisplayItem(table, element, index, binder, item, style, invalidStyle, null, manager); }
public override void ResetPersonalizationState(WebPartManager webPartManager) { base.ResetPersonalizationState(webPartManager); }
public override PersonalizationScope DetermineInitialScope( WebPartManager webPartManager, PersonalizationState loadedState) { return(base.DetermineInitialScope(webPartManager, loadedState)); }
public override IDictionary DetermineUserCapabilities( WebPartManager webPartManager) { return(base.DetermineUserCapabilities(webPartManager)); }
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(); } }
// Constructors public WebPartPersonalization(WebPartManager owner) { }
public virtual PersonalizationScope DetermineInitialScope(WebPartManager webPartManager, PersonalizationState loadedState) { }
protected override void LoadPersonalizationBlobs(WebPartManager webPartManager, string path, string userName, ref byte[] sharedDataBlob, ref byte[] userDataBlob) { base.LoadPersonalizationBlobs(webPartManager, "master", userName, ref sharedDataBlob, ref userDataBlob); }
public virtual PersonalizationState LoadPersonalizationState(WebPartManager webPartManager, bool ignoreCurrentUser) { }
protected override void ResetPersonalizationBlob(WebPartManager webPartManager, string path, string userName) { base.ResetPersonalizationBlob(webPartManager, "master", userName); }
// public String CurrentBlockButtonDetails = ""; protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as BlockButtons; SPWebPartManager webPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page); Guid WebPartGuid = webPartManager.GetStorageKey(webPart); WebPartUniqueID = WebPartGuid.ToString().Replace("-", String.Empty);; if (IsPostBack) { if (NeedToSave.Value == "true") { WBLogging.Debug("Saving the new details: " + BlockButtonsDetails.Value); string[] newDetails = BlockButtonsDetails.Value.WBxTrim().Split(','); if (newDetails.Length != 5) { WBLogging.Debug("The details sent to this page have the wrong structure: " + BlockButtonsDetails.Value); return; } webPart.BlockButtonsWidth = WBUtils.PutBackDelimiterCharacters(newDetails[0]); webPart.BlockButtonsHeight = WBUtils.PutBackDelimiterCharacters(newDetails[1]); webPart.BlockButtonsDetails = WBUtils.PutBackDelimiterCharacters(newDetails[2]); // We're not editing this extra parts via the pop-up dialog so we're not saving them either - this code is here just for illustration: // webPart.CssExtraClass = WBUtils.PutBackDelimiterCharacters(newDetails[3]); // webPart.CssExtraStyles = WBUtils.PutBackDelimiterCharacters(newDetails[4]); webPartManager.SaveChanges(WebPartGuid); SPContext.Current.Web.Update(); } } CSSExtraClass = webPart.CssExtraClass; CSSExtraStyles = webPart.CssExtraStyles; SetHeight = webPart.BlockButtonsHeight; String html = ""; String[] buttonsDetails = webPart.BlockButtonsDetails.Split('^'); int index = 0; foreach (String buttonDetails in buttonsDetails) { string[] details = buttonDetails.Split('|'); string title = details[0].Trim(); string link = details[1].Trim(); string extraText = details[2].Trim(); string buttonColor = details[3].Trim(); int buttonBorderColorIndex = 4; int textColorIndex = 5; if (details.Length > 6) { buttonBorderColorIndex = 5; textColorIndex = 7; } string buttonBorderColor = details[buttonBorderColorIndex].Trim(); string textColor = details[textColorIndex].Trim(); html += "<td>\n<a class=\"block-button-link " + CSSExtraClass + "\" id=\"wbf-block-button-link-" + WebPartUniqueID + "-" + index + "\" href=\"" + link + "\">\n"; html += "<div class=\"block-button block-button-group-" + WebPartUniqueID + " " + CSSExtraClass + "\" id=\"wbf-block-button-" + WebPartUniqueID + "-" + index + "\" style=\"background-color: " + buttonColor + "; border-color: " + buttonBorderColor + "; color: " + textColor + "; width: " + webPart.BlockButtonsWidth + "; height: " + webPart.BlockButtonsHeight + ";\">\n"; html += "<div class=\"block-button-content " + CSSExtraClass + "\">\n"; html += "<div class=\"block-button-title " + CSSExtraClass + "\" id=\"wbf-block-button-title-" + WebPartUniqueID + "-" + index + "\" " + ((String.IsNullOrEmpty(title)) ? " style=\" display: none;\"" : "") + ">" + title + "</div>\n"; html += "<div class=\"block-button-extra-text " + CSSExtraClass + "\" id=\"wbf-block-button-extra-text-" + WebPartUniqueID + "-" + index + "\" " + ((String.IsNullOrEmpty(extraText)) ? " style=\" display: none;\"" : "") + ">" + extraText + "</div> \n"; html += "</div></div></a></td>"; index++; } BlockButtons.Text = html; if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) || (webPartManager.DisplayMode == WebPartManager.EditDisplayMode)) { String[] detailsToEdit = new String[5]; detailsToEdit[0] = WBUtils.ReplaceDelimiterCharacters(webPart.BlockButtonsWidth); detailsToEdit[1] = WBUtils.ReplaceDelimiterCharacters(webPart.BlockButtonsHeight); detailsToEdit[2] = WBUtils.ReplaceDelimiterCharacters(webPart.BlockButtonsDetails.WBxTrim()); detailsToEdit[3] = WBUtils.ReplaceDelimiterCharacters(webPart.CssExtraClass); detailsToEdit[4] = WBUtils.ReplaceDelimiterCharacters(webPart.CssExtraStyles); String currentDetails = String.Join(",", detailsToEdit); currentDetails = HttpUtility.UrlEncode(currentDetails); BlockButtonsDetails.Value = currentDetails; InEditMode = true; EditBlockButtonsButton.OnClientClick = "WBF_editBlockButtons(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + BlockButtonsDetails.ClientID + "\"); return false;"; } else { EditBlockButtonsButton.OnClientClick = ""; } ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "UpdateBlockButtons" + WebPartUniqueID, String.Format("WBF_checkBlockButtonsHeights('{0}', '{1}');", WebPartUniqueID, SetHeight), true); }
protected override void SavePersonalizationBlob(WebPartManager webPartManager, string path, string userName, byte[] dataBlob) { base.SavePersonalizationBlob(webPartManager, "master", userName, dataBlob); }
protected override void LoadPersonalizationBlobs(WebPartManager webPartManager, string path, string userName, ref byte[] sharedDataBlob, ref byte[] userDataBlob) { sharedDataBlob = LoadBlob(path); }
public AdminWebPartPersonalization(WebPartManager webPartManager) : base(webPartManager) { }
public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager) { throw new NotImplementedException(); }
public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager) { if (null == container) { throw new ArgumentNullException("container"); } if (null == config) { throw new ArgumentNullException("config"); } if (!(config is IConfigurationSection)) { throw new ArgumentException("config must be an IConfigurationSection"); } if ((config as IConfigurationSection).Elements.ContainsKey("totals")) { Table table; if (container is Table) { table = (container as Table); } else { table = new Table(); table.ApplyStyle(templatable.TotalsStyle); } IConfigurationElement element = (config as IConfigurationSection).GetElementReference("totals"); foreach (IConfigurationElement rowElement in element.Elements.Values) { this.DisplayItem(table, rowElement, "totals" + itemIndex.ToString(), binder, item, templatable.TotalsRowStyle, templatable.InvalidItemStyle, manager); } if (!(container is Table)) { container.Controls.Add(table); } } }
public virtual void Extract(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, IEnumerable registry, ITemplatingItem item, int itemIndex, int itemsCount, WebPartManager manager) { throw new NotImplementedException(); }
public override PersonalizationState LoadPersonalizationState(WebPartManager webPartManager, bool ignoreCurrentUser) { return(base.LoadPersonalizationState(webPartManager, ignoreCurrentUser)); }
public virtual void DisplayItem(Table table, IConfigurationElement element, string index, IBinder binder, ITemplatingItem item, TableItemStyle style, TableItemStyle invalidStyle, Dictionary <string, Control> registry, WebPartManager manager) { string[] span = null; if (element.Attributes.ContainsKey("span") && null != element.GetAttributeReference("span").Value) { span = element.GetAttributeReference("span").Value.ToString().Split(new char[] { ',' }); } string[] rowspan = null; if (element.Attributes.ContainsKey("rowspan") && null != element.GetAttributeReference("rowspan").Value) { rowspan = element.GetAttributeReference("rowspan").Value.ToString().Split(new char[] { ',' }); } TableRow tr = new TableRow(); tr.ID = string.Concat(new string[] { table.ID, "-", element.ConfigKey, "-", index }); tr.Attributes["key"] = element.ConfigKey; tr.ApplyStyle(style); foreach (IConfigurationElementAttribute attribute in element.Attributes.Values) { if ("span" != attribute.ConfigKey && "rowspan" != attribute.ConfigKey) { tr.Style.Add(attribute.ConfigKey, attribute.Value.ToString()); } } table.Rows.Add(tr); int count = 0; foreach (IConfigurationElement controlElement in element.Elements.Values) { TableCell tc = new TableCell(); tc.ID = tr.ID + "-" + controlElement.ConfigKey; tc.Attributes["key"] = controlElement.ConfigKey; if (span != null && span.Length > count) { int columnSpan = 1; int.TryParse(span[count], out columnSpan); tc.ColumnSpan = columnSpan; if (rowspan != null && rowspan.Length > count) { int rowSpan = 1; int.TryParse(rowspan[count], out rowSpan); tc.RowSpan = rowSpan; } count++; } tr.Cells.Add(tc); string pullpush = null; foreach (IConfigurationElement propertyElement in controlElement.Elements.Values) { if (propertyElement.Attributes.ContainsKey("for") && "cell" == propertyElement.GetAttributeReference("for").Value.ToString() && propertyElement.Attributes.ContainsKey("member") && propertyElement.Attributes.ContainsKey("value")) { try { ReflectionServices.SetValue(tc, propertyElement.GetAttributeReference("member").Value.ToString(), propertyElement.GetAttributeReference("value").Value); } catch (Exception ex) { ControlFactory.Instance.Monitor.Register(ControlFactory.Instance, ControlFactory.Instance.Monitor.NewEventInstance("set cell attributes error", null, ex, EVENT_TYPE.Error)); } } if (propertyElement.Attributes.ContainsKey("pull")) { pullpush = propertyElement.GetAttributeReference("pull").Value.ToString(); } else { if (propertyElement.Attributes.ContainsKey("push")) { pullpush = propertyElement.GetAttributeReference("push").Value.ToString(); } } } Control cellControl = ControlFactory.Instance.CreateControl(controlElement, index, binder, item, tc, invalidStyle, registry, manager); if (null != cellControl) { cellControl.ID = string.Concat(new string[] { table.ID, "-", element.ConfigKey, "-", index, "-", controlElement.ConfigKey, "-ctrl" }); tc.Controls.Add(cellControl); if (cellControl is BaseDataBoundControl && !string.IsNullOrEmpty(pullpush)) { if (!item.BoundControls.ContainsKey(pullpush)) { item.BoundControls.Add(pullpush, new List <BaseDataBoundControl>()); } item.BoundControls[pullpush].Add((BaseDataBoundControl)cellControl); } } } }
public override void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager) { this.Create(container, config, templatable, binder, item, itemIndex, manager, false); }
public virtual void Create(Control container, IConfigurationType config, ITemplatable templatable, IBinder binder, ITemplatingItem item, int itemIndex, WebPartManager manager, bool keepTable) { if (null == container) { throw new ArgumentNullException("container"); } if (null == config) { throw new ArgumentNullException("config"); } if (!(config is IConfigurationSection)) { throw new ArgumentException("config must be an IConfigurationSection"); } Table containerTable; if (container is Table) { containerTable = (container as Table); } else { containerTable = new Table(); containerTable.ID = container.ID + "grouping"; } IConfigurationElement element = (config as IConfigurationSection).GetElementReference("grouping"); Table table; if (keepTable) { table = containerTable; } else { TableRow tr = new TableRow(); TableCell tc = new TableCell(); table = new Table(); tr.ID = "groupingTable" + itemIndex.ToString() + "row"; tc.ID = "groupingTable" + itemIndex.ToString() + "cell"; table.ID = "groupingTable" + itemIndex.ToString(); tc.Controls.Add(table); tr.Cells.Add(tc); containerTable.Rows.Add(tr); if (element.Attributes.ContainsKey("span")) { int columnSpan = 1; int.TryParse(element.GetAttributeReference("span").Value.ToString(), out columnSpan); tc.ColumnSpan = columnSpan; } if (element.Attributes.ContainsKey("rowspan")) { int rowSpan = 1; int.TryParse(element.GetAttributeReference("rowspan").Value.ToString(), out rowSpan); tc.RowSpan = rowSpan; } } table.ApplyStyle(templatable.GroupingStyle); foreach (IConfigurationElement rowElement in element.Elements.Values) { this.DisplayItem(table, rowElement, "grouping" + itemIndex.ToString(), binder, item, templatable.GroupRowStyle, templatable.InvalidItemStyle, manager); } if (!(container is Table)) { container.Controls.Add(containerTable); } }
public MyWebPartChrome(WebPartZoneBase aZone, WebPartManager aManager) : base(aZone, aManager) { theZone = aZone; theManager = aManager; }
// Constructors public WebPartChrome(WebPartZoneBase zone, WebPartManager manager) { }