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


C# SPSite.MakeFullUrl方法代码示例

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


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

示例1: Delete

        /// <summary>
        /// Deletes the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        internal static void Delete(SPList list, bool force)
        {
            if (list == null)
                throw new SPException("List not found.");

            if (!list.AllowDeletion && force)
            {
                list.AllowDeletion = true;
                list.Update();
            }
            else if (!list.AllowDeletion)
                throw new SPException("List cannot be deleted.  Try using the '-force' parameter to force the delete.");

            try
            {
                list.Delete();
            }
            catch (Exception)
            {
                if (force)
                {
                    using (SPSite site = new SPSite(list.ParentWeb.Site.ID))
                    {
                        Utilities.RunStsAdmOperation(
                            string.Format(" -o forcedeletelist -url \"{0}\"",
                                          site.MakeFullUrl(list.RootFolder.ServerRelativeUrl)), false);
                    }
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:35,代码来源:DeleteList.cs

示例2: CreatePage

 /// <summary>
 /// Creates the page.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="pageName">Name of the page.</param>
 /// <param name="title">The title.</param>
 /// <param name="layoutName">Name of the layout.</param>
 /// <param name="fieldDataCollection">The field data collection.</param>
 public static string CreatePage(string url, string pageName, string title, string layoutName, Dictionary<string, string> fieldDataCollection, bool test)
 {
     using (SPSite site = new SPSite(url))
     using (SPWeb web = site.AllWebs[Utilities.GetServerRelUrlFromFullUrl(url)])
     {
         PublishingPage page = CreatePage(web, pageName, title, layoutName, fieldDataCollection, test);
         return site.MakeFullUrl(page.Url);
     }
 }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:17,代码来源:CreatePublishingPage.cs

示例3: RemoveWebPart

        public static void RemoveWebPart(SPWeb spWeb)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(spWeb.Site.ID))
                {
                    using (SPWeb web = site.OpenWeb(spWeb.ID))
                    {
                        web.AllowUnsafeUpdates = true;
                        SPList bearchCampList = Utility.GetListFromURL(Constants.BEACH_CAMP_CALENDAR_LIST_URL, web);
                        string fullPageUrl = site.MakeFullUrl(bearchCampList.DefaultViewUrl);
                        SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(fullPageUrl, PersonalizationScope.Shared);
                        IEnumerable webPartList = from System.Web.UI.WebControls.WebParts.WebPart webPart in webPartManager.WebParts
                                                  where webPart.Title == bearchCampList.Title
                                                  select webPart;
                        foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in webPartManager.WebParts)
                        {
                            if (webPart is ListViewWebPart)//|| webPart is XsltListViewWebPart)
                            {
                                var listViewWebPart = webPart as ListViewWebPart;
                                //listViewWebPart.AllowMinimize = false;
                                //listViewWebPart.AllowClose = false;
                                //listViewWebPart.AllowHide = false;
                                //listViewWebPart.AllowZoneChange = false;
                                //listViewWebPart.AllowEdit = false;
                                //listViewWebPart.AllowConnect = false;
                                webPartManager.DeleteWebPart(listViewWebPart);
                                web.Update();
                                break;
                            }
                        }

                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
        }
开发者ID:dangquocthai,项目名称:beachcamp,代码行数:37,代码来源:SharePoint.EventReceiver.cs

示例4: SPCrossListQeuryInfo_Click

        private void SPCrossListQeuryInfo_Click(object sender, EventArgs e)
        {
            using (SPSite _site = new SPSite("http://home/"))
            {
                using (SPWeb _web = _site.OpenWeb())
                {
                    CrossListQueryInfo query = new CrossListQueryInfo();
                    query.RowLimit = 100;
                    query.WebUrl = _web.ServerRelativeUrl;
                    query.Query = "<Where><Neq><FieldRef Name=\"ContentType\" /><Value Type=\"Text\"></Value></Neq></Where>";

                    ////////////////////////////////////////
                    /////// ------------------------- //////
                    /////// BaseType 	        Value //////
                    /////// ------------------------- //////
                    /////// Generic List	    0     //////
                    /////// Document Library	1     //////
                    /////// Discussion Board	3     //////
                    /////// Survey	            4     //////
                    /////// Issue	            5     //////
                    ////////////////////////////////////////

                    // Search in doclibs only
                    query.Lists = "<Lists BaseType='1' />";
                    // Only .doc files
                    query.Query =
                    @"<Where>
              <Eq>
            <FieldRef Name='DocIcon' />
            <Value Type='Computed'>docx</Value>
              </Eq>
            </Where>";

                    // Select only needed columns: file reference
                    query.ViewFields = "<FieldRef Name='FileRef' />";

                    // Search in all webs of the site collection

                    query.Webs = "<Webs Scope='SiteCollection' />";

                    CrossListQueryCache cache = new CrossListQueryCache(query);

                    // Perform the query
                    DataTable table = cache.GetSiteData(_web);
                    // Generate an absolute url for each document
                    foreach (DataRow row in table.Rows)
                    {
                        string relativeUrl =
                          row["FileRef"].ToString().Substring(
                            row["FileRef"].ToString().IndexOf("#") + 1);
                        string fullUrl = _site.MakeFullUrl(relativeUrl);

                        // Write urls to console
                        MessageBox.Show(fullUrl);
                    }
                }
            }
        }
开发者ID:Praveenmanne,项目名称:SiteDataQuery,代码行数:58,代码来源:Qeury.cs

示例5: getFullUrl

        public string getFullUrl(string relativeUrl)
        {
            string url = "";

            using (SPSite site = new SPSite(SiteUrl))
            {
                url = site.MakeFullUrl(relativeUrl);
            }
            return (url);
        }
开发者ID:dreamibr,项目名称:DocExtractor,代码行数:10,代码来源:DocExtractor.cs

示例6: LoadBanner

        private void LoadBanner()
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb web = site.OpenWeb(SPContext.Current.Site.RootWeb.ID))
                        {
                            SPList spList = Utility.GetListFromURL(Constants.BANNER_LIBRARY_URL, web);
                            string banners = string.Empty;
                            if (spList != null)
                            {
                                SPFolder spFolder = spList.RootFolder;

                                if (!string.IsNullOrEmpty(BannerFolder))
                                {
                                    SPFolderCollection folderCollection = spFolder.SubFolders;

                                    foreach (SPFolder folder in folderCollection)
                                    {
                                        if (spFolder.Name == "Attachments" || spFolder.Item == null) continue;
                                        if (spFolder.Item.Name == BannerFolder)
                                        {
                                            spFolder = folder;
                                            break;
                                        }
                                    }
                                }

                                SPQuery spQuery = new SPQuery();
                                spQuery.Query = "<OrderBy><FieldRef Name='OrderNumber'/></OrderBy>";
                                spQuery.Folder = spFolder;

                                SPListItemCollection spItemCollection = spList.GetItems(spQuery);

                                foreach (SPItem spItem in spItemCollection)
                                {
                                    if (Convert.ToBoolean(spItem["Active"]))
                                    {
                                        banners += string.Format(liSlideShow, string.Format("{0}/{1}", site.MakeFullUrl(spFolder.ServerRelativeUrl), spItem["Name"]), spItem["Title"], spItem["Description"], spItem["RelatedLink"], '"');
                                    }
                                }
                            }
                            ulThumbList.InnerHtml = banners;
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Utility.LogError(ex.Message, AIAPortalFeatures.Infrastructure);
            }
        }
开发者ID:chutinhha,项目名称:aiaintranet,代码行数:55,代码来源:BannerSlideShowUserControl.ascx.cs

示例7: Reghost

        /// <summary>
        /// Reghosts the specified file.
        /// </summary>
        /// <param name="site">The site.</param>
        /// <param name="web">The web.</param>
        /// <param name="file">The file.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="throwOnError">if set to <c>true</c> [throw on error].</param>
        public static void Reghost(SPSite site, SPWeb web, SPFile file, bool force, bool throwOnError)
        {
            try
            {
                string fileUrl = site.MakeFullUrl(file.ServerRelativeUrl);
                if (file.CustomizedPageStatus != SPCustomizedPageStatus.Customized && !force)
                {
                    Logger.Write("Progress: " + file.ServerRelativeUrl + " was not unghosted (customized).");
                    return;
                }
                if (file.CustomizedPageStatus != SPCustomizedPageStatus.Customized && force)
                {
                    if (!string.IsNullOrEmpty((string)file.Properties["vti_setuppath"]))
                    {
                        file.Properties["vti_hasdefaultcontent"] = "false";

                        string setupPath = (string)file.Properties["vti_setuppath"];
                        string rootPath = Utilities.GetGenericSetupPath("Template");

                        if (!File.Exists(Path.Combine(rootPath, setupPath)))
                        {
                            string message = "The template file (" + Path.Combine(rootPath, setupPath) +
                                             ") does not exist so re-ghosting (uncustomizing) will not be possible.";

                            // something's wrong with the setup path - lets see if we can fix it
                            // Try and remove a leading locale if present
                            setupPath = "SiteTemplates\\" + setupPath.Substring(5);
                            if (File.Exists(Path.Combine(rootPath, setupPath)))
                            {
                                message += "  It appears that a possible template match does exist at \"" +
                                           Path.Combine(rootPath, setupPath) +
                                           "\" however this tool currently is not able to handle pointing the file to the correct template path.  This scenario is most likely due to an upgrade from SPS 2003.";

                                // We found a matching file so reset the property and update the file.
                                // ---  I wish this would work but it simply doesn't - something is preventing the
                                //      update from occuring.  Manipulating the database directly results in a 404
                                //      when attempting to load the "fixed" page so there's gotta be something beyond
                                //      just updating the setuppath property.
                                //file.Properties["vti_setuppath"] = setupPath;
                                //file.Update();
                            }
                            throw new FileNotFoundException(message, setupPath);
                        }
                    }
                }
                Logger.Write("Progress: Re-ghosting (uncustomizing) '{0}'", fileUrl);
                file.RevertContentStream();

                file = web.GetFile(fileUrl);
                if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
                {
                    // Still unsuccessful so take measures further
                    if (force)
                    {
                        object request = Utilities.GetSPRequestObject(web);

                        // I found some cases where calling this directly was the only way to force the re-ghosting of the file.
                        // I think the trick is that it's not updating the file properties after doing the revert (the
                        // RevertContentStream method will call SPRequest.UpdateFileOrFolderProperties() immediately after the
                        // RevertContentStreams call but ommitting the update call seems to make a difference.
                        Utilities.ExecuteMethod(request, "RevertContentStreams",
                                                new[] { typeof(string), typeof(string), typeof(bool) },
                                                new object[] { web.Url, file.Url, file.CheckOutStatus != SPFile.SPCheckOutStatus.None });

                        Utilities.ExecuteMethod(file, "DirtyThisFileObject", new Type[] { }, new object[] { });

                        file = web.GetFile(fileUrl);

                        if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
                        {
                            throw new SPException("Unable to re-ghost (uncustomize) file " + file.ServerRelativeUrl);
                        }
                        Logger.Write("Progress: " + file.ServerRelativeUrl + " was re-ghosted (uncustomized)!");
                        return;
                    }
                    throw new SPException("Unable to re-ghost (uncustomize) file " + file.ServerRelativeUrl);
                }
                Logger.Write("Progress: " + file.ServerRelativeUrl + " was re-ghosted (uncustomized)!");
            }
            catch (Exception ex)
            {
                if (throwOnError)
                {
                    throw;
                }
                Logger.WriteException(new ErrorRecord(ex, null, ErrorCategory.NotSpecified, file));
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:96,代码来源:ReGhostFile.cs

示例8: GetPublicUrl

 /// <summary>
 /// This Function return a Public URL for the Current Site.
 /// </summary>
 /// <returns>string</returns>
 private string GetPublicUrl()
 {
     string publicUrl = string.Empty;
     string _message = string.Empty;
     using (SPSite ObjSite = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.Zone))
     {
         publicUrl = ObjSite.MakeFullUrl(SPContext.Current.Site.ServerRelativeUrl);
     }
     return publicUrl;
 }
开发者ID:infinitimods,项目名称:clif-sharepoint,代码行数:14,代码来源:ApproversTask.cs


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