Пример #1
0
        /// <summary>
        /// Returns the WebDav URL for the current web.
        /// </summary>
        /// <param name="web"></param>
        /// <remarks>A webdav URL looks like: \\webapplicationurl@SSL\DavWWWRoot\sites\sitecollection</remarks>
        /// <returns></returns>
        public static string GetSiteWebDavUrl(this SPClient.Web web)
        {
            Uri    webUri    = new Uri(web.GetUrl());
            string webDavUrl = string.Format("\\\\{0}@SSL\\DavWWWRoot{1}", webUri.DnsSafeHost, webUri.AbsolutePath.Replace('/', '\\'));

            return(webDavUrl);
        }
Пример #2
0
        public static string GetSettingsUrl(this SPClient.Field field, TreeNode selectedNode)
        {
            // <sitecollection|web>/_layouts/FldEditEx.aspx?field=Instructie
            // <sitecollection|web>/_layouts/FldEdit.aspx?List=%7BCEBB8CB0%2DC088%2D4BEE%2DBF17%2DE6A8CD5F6C9F%7D&Field=Title

            if (selectedNode.Parent.Parent.Tag is SPClient.Site)
            {
                // <sitecollection>/_layouts/15/fldedit.aspx?field=%5FEndDate&Source=%2F%5Flayouts%2F15%2Fmngfield%2Easpx%3FFilter%3DAll%2520Groups

                SPClient.Site site = selectedNode.Parent.Parent.Tag as SPClient.Site;
                return(string.Format("{0}/_layouts/fldedit.aspx?field={1}", site.RootWeb.GetUrl(), field.InternalName));
            }
            else if (selectedNode.Parent.Parent.Tag is SPClient.Web)
            {
                // <sitecollection>/<web>/_layouts/15/fldedit.aspx?field=Sub%5Fx0020%5FSite%5Fx0020%5FColumn&Source=%2Fsub%2F%5Flayouts%2F15%2Fmngfield%2Easpx%3FFilter%3DAll%2520Groups

                SPClient.Web web = selectedNode.Parent.Parent.Tag as SPClient.Web;
                return(string.Format("{0}/_layouts/fldedit.aspx?field={1}", web.GetUrl(), field.InternalName));
            }
            else if (selectedNode.Parent.Parent.Tag is SPClient.List)
            {
                // <sitecollection>/<web>/_layouts/15/FldEditEx.aspx?List=%7B051E4502%2D504E%2D49C8%2DA815%2DF46BFD61911D%7D&Field=Modified

                SPClient.List list = selectedNode.Parent.Parent.Tag as SPClient.List;
                return(string.Format("{0}/_layouts/FldEditEx.aspx?list={1}&field={2}", list.ParentWeb.GetUrl(), list.Id, field.InternalName));
            }
            else
            {
                return(string.Empty);
            }
        }
        public static string GetAppRedirectUrl(this SPClient.AppInstance appInstance, TreeNode selectedNode)
        {
            // How do I use the appredirect page in the URL? You can use the app redirect page by URL-encoding, as follows:
            // https://sitecollection/web/_layouts/15/appredirect.aspx?instance_id=<AppClientId>&redirect_uri=<redirectURL>

            SPClient.Web web = (SPClient.Web)selectedNode.Parent.Parent.Tag;

            return(string.Format("{0}/_layouts/15/appredirect.aspx?instance_id={1}",
                                 web.GetUrl(),
                                 appInstance.Id));
        }
        public static string GetSettingsUrl(this SPClient.Feature feature, TreeNode selectedNode)
        {
            // Link: <sitecollection|web>/_layouts/ManageFeatures.aspx
            // Link: <sitecollection>/_layouts/ManageFeatures.aspx?Scope=Site

            if (selectedNode.Parent.Parent.Tag is SPClient.Site)
            {
                SPClient.Site site = selectedNode.Parent.Parent.Tag as SPClient.Site;
                return(string.Format("{0}/_layouts/ManageFeatures.aspx?Scope=Site", site.RootWeb.GetUrl()));
            }
            else
            {
                SPClient.Web web = selectedNode.Parent.Parent.Tag as SPClient.Web;
                return(string.Format("{0}/_layouts/ManageFeatures.aspx", web.GetUrl()));
            }
        }
        public static string GetSettingsUrl(this SPClient.ContentType ct, TreeNode selectedNode)
        {
            // Link: <sitecollection|web>/_layouts/ManageContentType.aspx?ctype=0x0101009148F5A04DDD49CBA7127AADA5FB792B006973ACD696DC4858A76371B2FB2F439A
            // Link: <sitecollection|web>/_layouts/ManageContentType.aspx?List=%7BF798C4D9%2DEF29%2D4F8D%2DA1F1%2D4C70CFBAECE4%7D&ctype=0x010100A204AFB24228A94AB2D6195EB1705291

            if (selectedNode.Parent.Parent.Tag is SPClient.Site)
            {
                SPClient.Site site = selectedNode.Parent.Parent.Tag as SPClient.Site;
                return(string.Format("{0}/_layouts/ManageContentType.aspx?ctype={1}", site.RootWeb.GetUrl(), ct.Id));
            }
            else if (selectedNode.Parent.Parent.Tag is SPClient.Web)
            {
                // <sitecollection>/<web>/_layouts/15/ManageContentType.aspx?ctype=0x00A7470EADF4194E2E9ED1031B61DA088403000BE6CEFFF1ACA6429D14B2B7E0A03FE2
                // <sitecollection>/<web>/_layouts/15/start.aspx#/_layouts/15/ManageContentType.aspx?ctype=0x00A7470EADF4194E2E9ED1031B61DA088403000BE6CEFFF1ACA6429D14B2B7E0A03FE2&Source=https%3A%2F%2Fbramdejager%2Esharepoint%2Ecom%2Fsub%2F%5Flayouts%2F15%2Fmngctype%2Easpx

                SPClient.Web web = selectedNode.Parent.Parent.Tag as SPClient.Web;
                return(string.Format("{0}/_layouts/ManageContentType.aspx?ctype={1}", web.GetUrl(), ct.Id));
            }
            else if (selectedNode.Parent.Parent.Tag is SPClient.List)
            {
                SPClient.List list = selectedNode.Parent.Parent.Tag as SPClient.List;
                return(string.Format("{0}/_layouts/ManageContentType.aspx?list={1}&ctype={2}", list.ParentWeb.GetUrl(), list.Id, ct.Id));
            }
            else
            {
                return(string.Empty);
            }
        }
Пример #6
0
 /// <summary>
 /// Returns the REST endpoint for current web.
 /// </summary>
 /// <param name="web"></param>
 /// <example>http://server/site/_api/web</example>
 /// <returns></returns>
 public static Uri GetRestUrl(this SPClient.Web web)
 {
     return(new Uri(string.Format("{0}/_api/web", web.GetUrl())));
 }
Пример #7
0
 /// <summary>
 /// Gets the Site Settings URL for the current web.
 /// </summary>
 /// <param name="web"></param>
 /// <returns>Returns Site Settings URL.</returns>
 public static string GetSettingsUrl(this SPClient.Web web)
 {
     return(web.GetUrl() + "/_layouts/settings.aspx");
 }
Пример #8
0
 /// <summary>
 /// Returns the REST endpoint for current field.
 /// </summary>
 /// <param name="field"></param>
 /// <example>http://server/site/_api/web/Fields</example>
 /// <example>http://server/site/_api/web/AvailableFields</example>
 /// <example>http://server/site/_api/web/AvailableFields(guid'56747800-d36e-4625-abe3-b1bc74a7d5f8')</example>
 /// <example>http://server/site/_api/web/lists(guid'81c57897-96ad-4b39-94d4-092be56d562d')/fields(guid'1d22ea11-1e32-424e-89ab-9fedbadb6ce1')</example>
 /// <returns></returns>
 public static Uri GetRestUrl(this SPClient.Field field, TreeNode selectedNode)
 {
     if (selectedNode.Parent.Parent.Tag is SPClient.Site)
     {
         SPClient.Site site = selectedNode.Parent.Parent.Tag as SPClient.Site;
         return(new Uri(string.Format("{0}/_api/Web/AvailableFields(guid'{1}')", site.RootWeb.GetUrl(), field.Id)));
     }
     else if (selectedNode.Parent.Parent.Tag is SPClient.Web)
     {
         SPClient.Web web = selectedNode.Parent.Parent.Tag as SPClient.Web;
         return(new Uri(string.Format("{0}/_api/Web/AvailableFields(guid'{1}')", web.GetUrl(), field.Id)));
     }
     else if (selectedNode.Parent.Parent.Tag is SPClient.List)
     {
         SPClient.List list = selectedNode.Parent.Parent.Tag as SPClient.List;
         return(new Uri(string.Format("{0}/_api/Web/Lists(guid'{1}')/Fields(guid'{2}')", list.ParentWeb.GetUrl(), list.Id, field.Id)));
     }
     else
     {
         return(null);
     }
 }