当前位置: 首页>>代码示例>>C#>>正文


C# SPWeb.GetLimitedWebPartManager方法代码示例

本文整理汇总了C#中SPWeb.GetLimitedWebPartManager方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.GetLimitedWebPartManager方法的具体用法?C# SPWeb.GetLimitedWebPartManager怎么用?C# SPWeb.GetLimitedWebPartManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPWeb的用法示例。


在下文中一共展示了SPWeb.GetLimitedWebPartManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddWebPartToPage

        public static string AddWebPartToPage(SPWeb web, string pageUrl, string webPartName, string zoneID, int zoneIndex)
        {
            try
            {
                web.AllowUnsafeUpdates = false;
                using (SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
                {
                    using (var webPart = CreateWebPart(web, webPartName, webPartManager))
                    {
                        if (webPart != null)
                        {
                            webPartManager.AddWebPart(webPart, zoneID, zoneIndex);
                            return webPart.ID;
                        }
                    }
                }

            }
            catch (Exception ex)
            {

                // throw;
            }
            finally
            {
                web.AllowUnsafeUpdates = false;
            }

            return string.Empty;
        }
开发者ID:chutinhha,项目名称:aiaintranet,代码行数:30,代码来源:PageHelper.cs

示例2: AddWebPartToPage

        /// <summary>
        /// Add the web part to page.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="pageUrl">The page URL.</param>
        /// <param name="webPartName">Name of the web part.</param>
        /// <param name="zoneID">The zone ID.</param>
        /// <param name="zoneIndex">Index of the zone.</param>
        /// <returns></returns>
        public static string AddWebPartToPage(SPWeb web, string pageUrl, string webPartName, string zoneID, int zoneIndex, bool isHidden)
        {
            using (SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(
                    pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
            {
                using (System.Web.UI.WebControls.WebParts.WebPart webPart = CreateWebPart(web, webPartName, webPartManager, isHidden))
                {
                    bool isExists = false;
                    foreach (System.Web.UI.WebControls.WebParts.WebPart wp in webPartManager.WebParts)
                    {
                        if (wp.Title.Equals(webPartName.Replace(".webpart", "")))
                        {
                            isExists = true;
                            break;
                        }
                        else
                        {
                            isExists = false;
                        }
                    }
                    if (!isExists)
                    {
                        webPartManager.AddWebPart(webPart, zoneID, zoneIndex);
                    }

                    return webPart.ID;
                }
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:38,代码来源:WebPartHelper.cs

示例3: AddWebPartToPage

 public static void AddWebPartToPage(SPWeb web, string pageUrl, string webPartName, string zoneId, int zoneIndex, bool flag)
 {
     try
     {
         // adding Web part if not exists on the workspace
         using (WebPart webPart = CreateWebPart(web, webPartName))
         {
             Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager manager;
             try
             {
                 manager = web.GetLimitedWebPartManager(pageUrl, PersonalizationScope.Shared);
             }
             catch (Exception)
             {
                 manager = null;
             }
             if (manager != null)
             {
                 webPart.ChromeType = PartChromeType.None;
                 manager.AddWebPart(webPart, zoneId, zoneIndex);
                 //  return webPart.ID;
                 manager.Dispose();
             }
         }
     }
     catch (Exception)
     {
         return;
     }
 }
开发者ID:Santhoshonet,项目名称:SP2010Library,代码行数:30,代码来源:WebPart.cs

示例4: AddXsltViewWebPart

 public static void AddXsltViewWebPart(SPWeb web, SPList list, string pageUrl, string webPartName, string zoneID,
     int zoneIndex, bool isHidden, string viewTitle)
 {
     using (SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(
             pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
     {
         bool isExists = false;
         foreach (System.Web.UI.WebControls.WebParts.WebPart wp in webPartManager.WebParts)
         {
             if (wp.Title.Equals(webPartName))
             {
                 isExists = true;
                 break;
             }
             else
             {
                 isExists = false;
             }
         }
         if (!isExists)
         {
             XsltListViewWebPart webPart = new XsltListViewWebPart();
             webPart.ListId = list.ID;
             webPart.Title = webPartName;
             webPart.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleAndBorder;
             SPView view = list.Views[viewTitle];
             webPart.ViewGuid = view.ID.ToString();
             webPart.XmlDefinition = view.GetViewXml();
             webPartManager.AddWebPart(webPart, zoneID, zoneIndex);
         }
     }
 }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:32,代码来源:WebPartHelper.cs

示例5: AssignJsLinkToListViews

 public static void AssignJsLinkToListViews(SPWeb web, SPView view, string jsLink)
 {
     SPLimitedWebPartManager limitedWebPartManager = null;
     XsltListViewWebPart providerWP = null;
     try {
         limitedWebPartManager = web.GetLimitedWebPartManager(view.Url, PersonalizationScope.Shared);
         providerWP = (from Microsoft.SharePoint.WebPartPages.WebPart webPart in limitedWebPartManager.WebParts where webPart is XsltListViewWebPart select webPart).First() as XsltListViewWebPart;
         providerWP.JSLink = jsLink;
         limitedWebPartManager.SaveChanges(providerWP);
         logger.Trace("jsLink "+ jsLink +" for" + view.Title + " assigned successfully");
     }
     catch (Exception ex) {
         logger.Error("jsLink " + jsLink + " not assigned! With error: ", ex.Message);
     }
     finally {
         if (limitedWebPartManager != null) {
             if (limitedWebPartManager.Web != null) {
                 limitedWebPartManager.Web.Dispose();
             }
             limitedWebPartManager.Dispose();
         }
         providerWP.Dispose();
     }
 }
开发者ID:Netbah,项目名称:SharePoint,代码行数:24,代码来源:ListHelper.cs

示例6: AddWebPartContentEditor

 public static void AddWebPartContentEditor(SPWeb web, string pageUrl, string zoneID, int zoneIndex, string testForContentEditor, string link, PartChromeType cromeType, string title)
 {
     try
     {
         ContentEditorWebPart contentEditor = new ContentEditorWebPart();
         XmlDocument xmlDoc = new XmlDocument();
         XmlElement xmlElement = xmlDoc.CreateElement("HtmlContent");
         xmlElement.InnerText = testForContentEditor;
         contentEditor.Content = xmlElement;
         using (SPLimitedWebPartManager manager =
           web.GetLimitedWebPartManager(pageUrl, PersonalizationScope.Shared))
         {
             contentEditor.ChromeType = cromeType;
             contentEditor.ContentLink = link;
             contentEditor.Title = title;
             manager.AddWebPart(contentEditor, zoneID, zoneIndex);
         }
     }
     catch (Exception ee)
     {
         EssnLog.logInfo("Error on AddWebPartContentEditor in FeatureActivated.");
         EssnLog.logExc(ee);
     }
 }
开发者ID:iburykin,项目名称:SFPU-Branding,代码行数:24,代码来源:Utility.cs

示例7: ReplaceValues

        /// <summary>
        /// Replaces the content of a <see cref="MediaWebPart"/> web part.
        /// </summary>
        /// <param name="web">The web that the file belongs to.</param>
        /// <param name="file">The file that the web part is associated with.</param>
        /// <param name="settings">The settings object containing user provided parameters.</param>
        /// <param name="wp">The web part whose content will be replaced.</param>
        /// <param name="regex">The regular expression object which contains the search pattern.</param>
        /// <param name="manager">The web part manager.  This value may get updated during this method call.</param>
        /// <param name="wasCheckedOut">if set to <c>true</c> then the was checked out prior to this method being called.</param>
        /// <param name="modified">if set to <c>true</c> then the web part was modified as a result of this method being called.</param>
        /// <returns>The modified web part.  This returned web part is what must be used when saving any changes.</returns>
        internal static WebPart ReplaceValues(SPWeb web,
           SPFile file,
           Settings settings,
           MediaWebPart wp,
           Regex regex,
           ref SPLimitedWebPartManager manager,
           ref bool wasCheckedOut,
           ref bool modified)
        {
            if (string.IsNullOrEmpty(wp.MediaSource) && string.IsNullOrEmpty(wp.TemplateSource) && string.IsNullOrEmpty(wp.PreviewImageSource))
                return wp;

            bool isMediaSourceMatch = false;
            if (!string.IsNullOrEmpty(wp.MediaSource))
                isMediaSourceMatch = regex.IsMatch(wp.MediaSource);

            bool isTemplateSourceMatch = false;
            if (!string.IsNullOrEmpty(wp.TemplateSource))
                isTemplateSourceMatch = regex.IsMatch(wp.TemplateSource);

            bool isPreviewImageSourceMatch = false;
            if (!string.IsNullOrEmpty(wp.PreviewImageSource))
                isPreviewImageSourceMatch = regex.IsMatch(wp.PreviewImageSource);

            if (!isMediaSourceMatch && !isTemplateSourceMatch && !isPreviewImageSourceMatch)
                return wp;

            string mediaSourceContent = wp.MediaSource;
            string templateSourceContent = wp.TemplateSource;
            string previewImageSourceContent = wp.PreviewImageSource;

            string mediaSourceResult = mediaSourceContent;
            string templateSourceResult = templateSourceContent;
            string previewImageSourceResult = previewImageSourceContent;

            if (!string.IsNullOrEmpty(mediaSourceContent))
                mediaSourceResult = regex.Replace(mediaSourceContent, settings.ReplaceString);
            if (!string.IsNullOrEmpty(templateSourceContent))
                templateSourceResult = regex.Replace(templateSourceContent, settings.ReplaceString);
            if (!string.IsNullOrEmpty(previewImageSourceContent))
                previewImageSourceResult = regex.Replace(previewImageSourceContent, settings.ReplaceString);

            if (isMediaSourceMatch)
                Logger.Write("Match found: File={0}, WebPart={1}, Replacement={2} => {3}",
                                  file.ServerRelativeUrl, wp.Title, mediaSourceContent, mediaSourceResult);
            if (isTemplateSourceMatch)
                Logger.Write("Match found: File={0}, WebPart={1}, Replacement={2} => {3}",
                                  file.ServerRelativeUrl, wp.Title, templateSourceContent, templateSourceResult);
            if (isPreviewImageSourceMatch)
                Logger.Write("Match found: File={0}, WebPart={1}, Replacement={2} => {3}",
                                  file.ServerRelativeUrl, wp.Title, previewImageSourceContent, previewImageSourceResult);
            if (!settings.Test)
            {
                if (file.CheckOutType == SPFile.SPCheckOutType.None)
                {
                    file.CheckOut();
                    wasCheckedOut = false;
                }
                // We need to reset the manager and the web part because a checkout (now or from an earlier call)
                // could mess things up so safest to just reset every time.
                manager.Web.Dispose(); // manager.Dispose() does not dispose of the SPWeb object and results in a memory leak.
                manager.Dispose();
                manager = web.GetLimitedWebPartManager(file.Url, PersonalizationScope.Shared);

                wp.Dispose();
                wp = (MediaWebPart)manager.WebParts[wp.ID];

                if (isMediaSourceMatch)
                    wp.MediaSource = mediaSourceResult;
                if (isTemplateSourceMatch)
                    wp.TemplateSource = templateSourceResult;
                if (isPreviewImageSourceMatch)
                    wp.PreviewImageSource = previewImageSourceResult;

                modified = true;
            }
            return wp;
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:90,代码来源:ReplaceWebPartContent.cs

示例8: getJSLinkFromView

 internal static string getJSLinkFromView(SPWeb web, SPView view)
 {
     SPLimitedWebPartManager limitedWebPartManager = null;
     XsltListViewWebPart providerWP = null;
     try {
         limitedWebPartManager = web.GetLimitedWebPartManager(view.Url, PersonalizationScope.Shared);
         providerWP = (from Microsoft.SharePoint.WebPartPages.WebPart webPart in limitedWebPartManager.WebParts where webPart is XsltListViewWebPart select webPart).First() as XsltListViewWebPart;
         logger.Trace("jsLink for" + view.Title + " got");
         return providerWP.JSLink;
     }
     catch (Exception ex) {
         logger.Error("jsLink " + view.Title + " not got! With error: ", ex.Message);
         return "";
     }
     finally {
         if (limitedWebPartManager != null) {
             if (limitedWebPartManager.Web != null) {
                 limitedWebPartManager.Web.Dispose();
             }
             limitedWebPartManager.Dispose();
         }
         providerWP.Dispose();
     }
 }
开发者ID:Netbah,项目名称:SharePoint,代码行数:24,代码来源:ListHelper.cs

示例9: SetUpDocumentWorkspace


//.........这里部分代码省略.........
               string presenter = string.Empty;
               if (eventProperties.ListItem["Presenter"] != null)
                   presenter = eventProperties.ListItem["Presenter"].ToString();

               AddAgendaToMeetingWorkspace(boardWeb, meetingWorkspaceURL, eventProperties.ListItem.Title, spUser, eventProperties.ListItemId, presenter, agendaOrder);
               }
               //Add the item to the Future Agenda List (Look Ahead list in EMIS)
               SPList lookAheadListInEMIS = eventProperties.Web.Lists[lookAheadListNameInEmis];
               SPListItem futureAgendaItem = lookAheadListInEMIS.AddItem();
               futureAgendaItem["Board Agenda"] = eventProperties.ListItem.Title;
               futureAgendaItem["Board Meeting"] = meetingTitle;
               futureAgendaItem["Meeting Date"] = meetingDate;
               futureAgendaItem["AgendaID"] = eventProperties.ListItemId;
               futureAgendaItem["ResponsiblePerson"] = spUser.Name;
               futureAgendaItem["Office"] = eventProperties.ListItem["AGM Office"].ToString();
               futureAgendaItem["Committee Meeting ID"] = eventProperties.ListItem["CommitteeMeeting"].ToString();
               futureAgendaItem["Agenda Status"] = "Agenda Created";
               futureAgendaItem["DocumentWorkspace"] = eventProperties.ListItem["DocumentWorkspace"].ToString();
               futureAgendaItem.Update();

               //Add the Link Item
               SPListItem newMeetingLink = documentWorkspace.Lists["Links"].Items.Add();

               newMeetingLink["URL"] = meetingWorkspaceURL;
               newMeetingLink.Update();

               SPWorkflowTemplate template = null;
               //Now associate the workflow
               //Activate all the necessary features on the site
               documentWorkspace.Features.Add(new Guid("24512e0e-7b03-466e-9209-38b39a51c581")); // Board Agenda Workflow

               foreach (SPWorkflowTemplate localwfTemplate in documentWorkspace.WorkflowTemplates)
               {
               if (localwfTemplate.Name == "BoardAgendaWorkflow") //TODO: This should come from configuration.
               {
                   template = localwfTemplate;
               }
               }
               if (template == null) // If the template was not in the document workspace, then check root web for it.
               {
               foreach (SPWorkflowTemplate wfTemplate in rootWeb.RootWeb.WorkflowTemplates)
               {
                   if (wfTemplate.Name == "BoardAgendaWorkflow") //TODO: This should come from configuration.
                   {
                       template = wfTemplate;
                   }
               }
               }
               //Delete the default task list that is created
               SPList defaultTaskList = documentWorkspace.Lists["Tasks"];
               documentWorkspace.Lists.Delete(defaultTaskList.ID);

               //After a Document Set is created, Create two lists in this Document Set
               //1. Workflow History
               //2. Agenda WF Tasks

               Guid taskListID = documentWorkspace.Lists.Add("Agenda Tasks", "This task list holds all the tasks associated with the Agenda Workflow", rootWeb.RootWeb.ListTemplates["Agenda Tasks"]); //TODO: Get this from configuration.
               //Guid taskListID = documentWorkspace.Lists.Add("Tasks", "", SPListTemplateType.Tasks);
               Guid historyListID = documentWorkspace.Lists.Add("Workflow History", "History list used by the Agenda Workflow", SPListTemplateType.WorkflowHistory);

               SPWorkflowAssociation workflowAssociation = SPWorkflowAssociation.CreateListAssociation(template, "Board Agenda Workflow", documentWorkspace.Lists[taskListID], documentWorkspace.Lists[historyListID]);
               workflowAssociation.AllowManual = true;
               workflowAssociation.AutoStartCreate = false;
               workflowAssociation.AutoStartChange = false;

               documentSet.ParentList.WorkflowAssociations.Add(workflowAssociation);

               SPList AgendaList = documentWorkspace.Lists[taskListID];
               AgendaList.EnableAssignToEmail = true;
               AgendaList.Update();

               SPList taskList = documentWorkspace.Lists[taskListID];
               taskList.OnQuickLaunch = true;
               taskList.Update();

               SPList historyList = documentWorkspace.Lists[historyListID];
               historyList.OnQuickLaunch = false;
               historyList.Update();

               //Remove the Announcements Webpart.
               SPLimitedWebPartManager webPartManager = documentWorkspace.GetLimitedWebPartManager("Default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

               for (int k = 0; k < webPartManager.WebParts.Count; k++)
               {
               //get reference to webpart
               WebPart wp = webPartManager.WebParts[k] as WebPart;

               //check webpart Title to find webpart which is to be removed
               if ((wp.Title == "Announcements") || (wp.Title == "Members"))
               {
                   //delete webpart
                   webPartManager.DeleteWebPart(webPartManager.WebParts[k]);

                   //update spWeb object
                   documentWorkspace.Update();
               }
               }

               documentWorkspace.AllowUnsafeUpdates = false;
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:101,代码来源:BoardAgendaReceiver.cs

示例10: SetUpDocumentWorkspace


//.........这里部分代码省略.........
               Guid historyListID = documentWorkspace.Lists.Add("Workflow History", "History list used by the Agenda Workflow", SPListTemplateType.WorkflowHistory);

               Guid keyPeopleListID = documentWorkspace.Lists.Add("Key People", "List of key people associated with this Agenda", rootWeb.RootWeb.ListTemplates["KeyPeopleDefinition"]);

               SPWorkflowAssociation workflowAssociation = SPWorkflowAssociation.CreateListAssociation(template, "Board Agenda Workflow", documentWorkspace.Lists[taskListID], documentWorkspace.Lists[historyListID]);
               workflowAssociation.AllowManual = true;
               workflowAssociation.AutoStartCreate = false;
               workflowAssociation.AutoStartChange = false;

               documentSet.ParentList.WorkflowAssociations.Add(workflowAssociation);

               SPWorkflowAssociation wfAssociationForNotifyCoordinators = SPWorkflowAssociation.CreateListAssociation(notifyCoordinatorsWFTemplate, "Notify Coordinators Workflow", documentWorkspace.Lists[taskListID], documentWorkspace.Lists[historyListID]);
               wfAssociationForNotifyCoordinators.AllowManual = true;
               wfAssociationForNotifyCoordinators.AutoStartCreate = false;
               wfAssociationForNotifyCoordinators.AutoStartChange = false;

               documentSet.ParentList.WorkflowAssociations.Add(wfAssociationForNotifyCoordinators);

               SPWorkflowAssociation wfAssociationForReviewContent = SPWorkflowAssociation.CreateListAssociation(reviewContentWFTemplate, "Review Content Workflow", documentWorkspace.Lists[taskListID], documentWorkspace.Lists[historyListID]);
               wfAssociationForReviewContent.AllowManual = true;
               wfAssociationForReviewContent.AutoStartCreate = false;
               wfAssociationForReviewContent.AutoStartChange = false;

               documentSet.ParentList.WorkflowAssociations.Add(wfAssociationForReviewContent);

               SPWorkflowAssociation wfAssociationForDigitalSignatures = SPWorkflowAssociation.CreateListAssociation(digitalSignaturesWFTemplate, "Digital Signatures", documentWorkspace.Lists[taskListID], documentWorkspace.Lists[historyListID]);
               wfAssociationForDigitalSignatures.AllowManual = true;
               wfAssociationForDigitalSignatures.AutoStartCreate = false;
               wfAssociationForDigitalSignatures.AutoStartChange = false;

               documentSet.ParentList.WorkflowAssociations.Add(wfAssociationForDigitalSignatures);

               SPList AgendaList = documentWorkspace.Lists[taskListID];
               AgendaList.EnableAssignToEmail = true;
               AgendaList.Update();

               SPList taskList = documentWorkspace.Lists[taskListID];
               taskList.OnQuickLaunch = true;
               taskList.Update();

               SPView defaultView = taskList.Views["All Tasks"];
               SPViewFieldCollection viewFields = defaultView.ViewFields;
               viewFields.Add(taskList.Fields["Comments"]);
               viewFields.Delete(taskList.Fields["Predecessors"]);
               viewFields.Delete(taskList.Fields["Description"]);

               defaultView.Update();

               SPList historyList = documentWorkspace.Lists[historyListID];
               historyList.OnQuickLaunch = false;
               historyList.Update();

               SPList keyPeopleList = documentWorkspace.Lists[keyPeopleListID];
               keyPeopleList.OnQuickLaunch = true;
               keyPeopleList.Update();

               SPList defaultCalendarList = documentWorkspace.Lists["Calendar"];
               defaultCalendarList.OnQuickLaunch = false;
               defaultCalendarList.Update();

               AddKeyPeopleToAgenda(rootWeb, documentWorkspace, keyPeopleListID, masterKeyPeopleListName, agendaType, eventProperties.ListItem["AGM Office"].ToString());

               string assemblyName = "PaperlessBoard EventHandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=072ce623fbaeb261";
               keyPeopleList.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, "PaperlessBoard_EventHandlers.KeyPeopleAddedEventReceiver.KeyPeopleAddedEventReceiver");
               keyPeopleList.EventReceivers.Add(SPEventReceiverType.ItemDeleted, assemblyName, "PaperlessBoard_EventHandlers.KeyPeopleAddedEventReceiver.KeyPeopleAddedEventReceiver");
               keyPeopleList.EventReceivers.Add(SPEventReceiverType.ItemUpdated, assemblyName, "PaperlessBoard_EventHandlers.KeyPeopleAddedEventReceiver.KeyPeopleAddedEventReceiver");

               //Remove the Announcements Webpart.
               SPLimitedWebPartManager webPartManager = documentWorkspace.GetLimitedWebPartManager("Default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

               for (int k = 0; k < webPartManager.WebParts.Count; k++)
               {
               //get reference to webpart
               WebPart wp = webPartManager.WebParts[k] as WebPart;

               //check webpart Title to find webpart which is to be removed
               if ((wp.Title == "Announcements") || (wp.Title == "Members"))
               {
                   //delete webpart
                   webPartManager.DeleteWebPart(webPartManager.WebParts[k]);

                   //update spWeb object
                   documentWorkspace.Update();
               }
               }

               AddWebPartsToWelcomePage(documentWorkspace, documentSet.WelcomePageUrl);

               try
               {
               CleanUpQuickLaunch(documentWorkspace);
               }
               catch (Exception ex)
               {
               Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception – {0} – {1} – {2}", "Error in Agenda Reciever while cleaning up quick launch.", ex.Message, ex.StackTrace);

               }

               documentWorkspace.AllowUnsafeUpdates = false;
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:101,代码来源:BoardAgendaReceiver.cs

示例11: AddWebPartsToWelcomePage

        private void AddWebPartsToWelcomePage(SPWeb documentWorkspace, string welcomePageURL)
        {
            SPLimitedWebPartManager webPartManager = documentWorkspace.GetLimitedWebPartManager(welcomePageURL, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

               string SiteURL = documentWorkspace.Site.RootWeb.Url;
               // Workflow Dashboard Web Part
               SilverlightWebPart swpWFDashboard = new SilverlightWebPart();
               swpWFDashboard.Url = string.Format(@"{0}/{1}/WorkflowDashboard.xap", SiteURL, "Apps") ;
               swpWFDashboard.Height = new Unit("200px");
               swpWFDashboard.Title = "Workflow Dashboard";
               swpWFDashboard.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleOnly;

               webPartManager.AddWebPart(swpWFDashboard, "Zone 2", 0);

               // Key Events Web part
               SilverlightWebPart swpKeyEvents = new SilverlightWebPart();
               swpKeyEvents.Url = string.Format(@"{0}/{1}/PaperlessBoardSLWebparts.xap", SiteURL, "Apps") ;
               swpKeyEvents.Title = "Key Events";
               swpKeyEvents.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleOnly;

               webPartManager.AddWebPart(swpKeyEvents, "Zone 2", 1);

               // Key People Web Part
               SilverlightWebPart swpActiveTasks = new SilverlightWebPart();
               swpActiveTasks.Url = string.Format(@"{0}/{1}/ActiveTasksForWorkspace.xap", SiteURL, "Apps");
               swpActiveTasks.Title = "Active Tasks";
               swpActiveTasks.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleOnly;

               webPartManager.AddWebPart(swpActiveTasks, "Zone 2", 2);

               // Key People Web Part
               SilverlightWebPart swpKeyPeople = new SilverlightWebPart();
               swpKeyPeople.Url = string.Format(@"{0}/{1}/PBSilverlightKeyPeopleInAgendaWP.xap", SiteURL, "Apps") ;
               swpKeyPeople.Title = "Key People";
               swpKeyPeople.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleOnly;
               swpKeyPeople.Height = new Unit("300px");
               webPartManager.AddWebPart(swpKeyPeople, "Zone 2", 3);

               documentWorkspace.Update();
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:40,代码来源:BoardAgendaReceiver.cs

示例12: GetLatestWebPartIndex

        public static int GetLatestWebPartIndex(SPWeb web, string pageUrl, string zoneId)
        {
            int idx = 0;

            try
            {
                string fullPageUrl = string.Format("{0}/{1}", web.Url.TrimEnd('/'), pageUrl.TrimStart('/'));

                SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(
                        fullPageUrl,
                        System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                foreach (System.Web.UI.WebControls.WebParts.WebPart wp in mgr.WebParts)
                {
                    if (string.IsNullOrEmpty(zoneId) || (!string.IsNullOrEmpty(zoneId) && mgr.GetZoneID(wp) == zoneId))
                    {
                        if (idx < wp.ZoneIndex) idx = wp.ZoneIndex;
                    }
                }
            }
            catch (Exception) { }

            return idx;
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:24,代码来源:WebPartHelper.cs

示例13: HideXsltListViewWebParts

        public static void HideXsltListViewWebParts(SPWeb web, string pageUrl)
        {
            try
            {
                string fullPageUrl = string.Format("{0}/{1}", web.Url.TrimEnd('/'), pageUrl.TrimStart('/'));

                SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(
                        fullPageUrl,
                        System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                foreach (System.Web.UI.WebControls.WebParts.WebPart wp in mgr.WebParts)
                {
                    if (wp is SP.XsltListViewWebPart)
                    {
                        wp.Hidden = true;
                        mgr.SaveChanges(wp);
                    }
                }
            }
            catch(Exception){}
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:20,代码来源:WebPartHelper.cs

示例14: MoveWebPart

        public static void MoveWebPart(SPWeb web, string pageUrl, string webPartName, string zoneID, int zoneIndex)
        {
            try
            {
                string fullPageUrl = string.Format("{0}/{1}", web.Url.TrimEnd('/'), pageUrl.TrimStart('/'));

                SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(
                        fullPageUrl,
                        System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                foreach (System.Web.UI.WebControls.WebParts.WebPart wp in mgr.WebParts)
                {
                    if (wp.Title.Equals(webPartName.Replace(".webpart", "")))
                    {
                        mgr.MoveWebPart(wp, zoneID, zoneIndex);
                        mgr.SaveChanges(wp);
                        break;
                    }
                }
            }
            catch (Exception) { }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:21,代码来源:WebPartHelper.cs

示例15: ProvisionWebpart

        public static void ProvisionWebpart(SPWeb web, WebpartPageDefinitionCollection collection)
        {
            foreach (var item in collection)
            {
                try
                {

                    string pageUrl = item.PageUrl;
                    if (!string.IsNullOrEmpty(item.RootPath) && !string.IsNullOrEmpty(item.FileName))
                    {
                        if (item.RootPath.EndsWith(".aspx"))
                        {
                            item.PageUrl = item.RootPath;
                            pageUrl = item.RootPath;
                        }

                        else
                        {
                            pageUrl = string.Format("{0}/{1}", item.RootPath.TrimEnd('/'), SPEncode.UrlEncode(item.FileName.TrimStart('/')));
                            item.PageUrl = pageUrl;
                        }
                    }

                    if (!IsAbsoluteUrl(pageUrl))
                    {
                        pageUrl = string.Format("{0}/{1}", web.Url.TrimEnd('/'), pageUrl.TrimStart('/'));
                    }

                    web.EnsureWebpartPage(item.PageUrl, item.Title, item.Overwrite);

                using (SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(
                    pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
                {

                    foreach (var wp in item.Webparts)
                    {
                        try
                        {
                            using (var concerateWP = wp.CreateWebPart(web, webPartManager))
                            {

                                if (concerateWP == null) continue;
                                try
                                {
                                    if (!wp.AllowDuplicate && webPartManager.WebParts.Cast<System.Web.UI.WebControls.WebParts.WebPart>().Any(p => p.Title == concerateWP.Title))
                                    {
                                        continue;
                                    }
                                }
                                catch (Exception)
                                {

                                    //throw;
                                }

                                webPartManager.AddWebPart(concerateWP, wp.ZoneId, wp.Index ==0 ?webPartManager.WebParts.Count+1:  wp.Index);

                                CreateDefaultWebPart(web, webPartManager, wp, concerateWP);
                            }
                        }
                        catch (Exception ex)
                        {

                        }

                    }
                }
                }
                catch (Exception ex)
                {

                }
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:74,代码来源:WebPartHelper.cs


注:本文中的SPWeb.GetLimitedWebPartManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。