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


C# Web类代码示例

本文整理汇总了C#中Web的典型用法代码示例。如果您正苦于以下问题:C# Web类的具体用法?C# Web怎么用?C# Web使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Connect

        public Web Connect(string url)
        {
            using (var site = CreateSite(url))
            {
                using (var web = site.OpenWeb())
                {
                    Web = new Web(this)
                    {
                        Id = web.ID,
                        Url = url,
                        Title = web.Title
                    };

                    Web.Lists = web.Lists.Cast<SPList>().Select(l => new SList
                    {
                        Web = Web,
                        Title = l.Title,
                        Id = l.ID,
                        IsHidden = l.Hidden
                    }).ToList();

                    return Web;
                }
            }
        }
开发者ID:konradsikorski,项目名称:smartCAML,代码行数:25,代码来源:SharePointOnlineProvider.cs

示例2: PersistFile

        internal void PersistFile(Web web, ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope, string folderPath, string fileName, Boolean decodeFileName = false)
        {
            if (creationInfo.FileConnector != null)
            {
                SharePointConnector connector = new SharePointConnector(web.Context, web.Url, "dummy");

                Uri u = new Uri(web.Url);
                if (folderPath.IndexOf(u.PathAndQuery, StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    folderPath = folderPath.Replace(u.PathAndQuery, "");
                }

                using (Stream s = connector.GetFileStream(fileName, folderPath))
                {
                    if (s != null)
                    {
                        creationInfo.FileConnector.SaveFileStream(decodeFileName ? HttpUtility.UrlDecode(fileName) : fileName, s);
                    }
                }
            }
            else
            {
                WriteWarning("No connector present to persist homepage.", ProvisioningMessageType.Error);
                scope.LogError("No connector present to persist homepage");
            }
        }
开发者ID:rgueldenpfennig,项目名称:PnP-Sites-Core,代码行数:26,代码来源:ObjectContentHandlerBase.cs

示例3: SetDocumentAsTemplate

        private static void SetDocumentAsTemplate(ClientContext cc, Web web)
        {
            ContentType ct = web.ContentTypes.GetById("0x0101009189AB5D3D2647B580F011DA2F356FB3");
            cc.Load(ct); 
            cc.ExecuteQuery();

            // Get instance to the _cts folder created for the each of the content types
            string ctFolderServerRelativeURL = "_cts/" + ct.Name;
            Folder ctFolder = web.GetFolderByServerRelativeUrl(ctFolderServerRelativeURL);
            cc.Load(ctFolder);
            cc.ExecuteQuery();

            // Load the local template document
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template.docx");
            string fileName = System.IO.Path.GetFileName(path);
            byte[] filecontent = System.IO.File.ReadAllBytes(path);

            // Uplaod file to the Office365
            using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open))
            {
                FileCreationInformation newFile = new FileCreationInformation();
                newFile.Content = filecontent;
                newFile.Url = ctFolderServerRelativeURL + "/" + fileName;

                Microsoft.SharePoint.Client.File uploadedFile = ctFolder.Files.Add(newFile);
                cc.Load(uploadedFile);
                cc.ExecuteQuery();
            }


            ct.DocumentTemplate = fileName;
            ct.Update(true);
            cc.ExecuteQuery();
            Console.WriteLine("Document template uploaded and set to the content type.");
        }
开发者ID:NicolajLarsen,项目名称:PnP,代码行数:35,代码来源:Program.cs

示例4: Edit

 public ActionResult Edit(int id, Web.Models.SlotModel model)
 {
     _wrapper.UpdateSlot(
         Mapper.Map<Model.SlotModel>(Mapper.Map<Model.SlotModel>(model))
     );
     return RedirectToAction("Index", new { taskId = model.TaskId });
 }
开发者ID:reaperdk,项目名称:timetracker,代码行数:7,代码来源:SlotsController.cs

示例5: DeployRegionalSettings

        private void DeployRegionalSettings(object modelHost, Web web, RegionalSettingsDefinition definition)
        {
            var settings = GetCurrentRegionalSettings(web);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            MapRegionalSettings(settings, definition);

            //web.RegionalSettings = settings;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:30,代码来源:RegionalSettingsModelHandler.cs

示例6: Validate

        public static bool Validate(CustomActions sourceCustomActions, CustomActions targetCustomActions, TokenParser tokenParser, Web web)
        {
            if (web.IsNoScriptSite())
            {
                Console.WriteLine("Skipping validation of custom actions due to noscript site.");
                return true;
            }

            Console.WriteLine("Custom Action validation started...");

            bool isSiteCustomActionsMatch = false;
            bool isWebCustomActionsMatch = false;
            if (sourceCustomActions.SiteCustomActions.Count > 0)
            {
                isSiteCustomActionsMatch = ValidateCustomActions(sourceCustomActions.SiteCustomActions, targetCustomActions.SiteCustomActions, tokenParser, web);
                Console.WriteLine("Site Custom Actions validation " + isSiteCustomActionsMatch);
            }

            if (sourceCustomActions.WebCustomActions.Count > 0)
            {
                isWebCustomActionsMatch = ValidateCustomActions(sourceCustomActions.WebCustomActions, targetCustomActions.WebCustomActions, tokenParser, web);
                Console.WriteLine("Web Custom  Actions validation " + isWebCustomActionsMatch);
            }

            if (!isSiteCustomActionsMatch || !isWebCustomActionsMatch)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
开发者ID:s-KaiNet,项目名称:PnP-Sites-Core,代码行数:33,代码来源:CustomActionValidator.cs

示例7: ProvisionObjects

 public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
 {
     using (var scope = new PnPMonitoredScope(this.Name))
     {
         var context = web.Context as ClientContext;
         foreach (var handler in template.ExtensibilityHandlers
             .Union(template.Providers)
             .Union(applyingInformation.ExtensibilityHandlers))
         {
             if (handler.Enabled)
             {
                 try
                 {
                     if (!string.IsNullOrEmpty(handler.Configuration))
                     {
                         //replace tokens in configuration data
                         handler.Configuration = parser.ParseString(handler.Configuration);
                     }
                     scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_extensibility_callout__0_, handler.Assembly);
                     _extManager.ExecuteExtensibilityProvisionCallOut(context, handler, template, applyingInformation, parser, scope);
                 }
                 catch (Exception ex)
                 {
                     scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_callout_failed___0_____1_, ex.Message, ex.StackTrace);
                     throw;
                 }
             }
         }
     }
     return parser;
 }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:31,代码来源:ObjectExtensibilityHandlers.cs

示例8: Edit

 public ActionResult Edit(int id, Web.Models.TaskModel model)
 {
     _wrapper.UpdateTask(
         Mapper.Map<Model.TaskModel>(Mapper.Map<Model.TaskModel>(model))
     );
     return RedirectToAction("Index", new { projectId = model.ProjectId });
 }
开发者ID:reaperdk,项目名称:timetracker,代码行数:7,代码来源:TasksController.cs

示例9: AddPublishingPage

        public static void AddPublishingPage(PublishingPage page, ClientContext ctx, Web web)
        {
            SPPublishing.PublishingPage publishingPage = web.GetPublishingPage(page.FileName + ".aspx");

            RemovePublishingPage(publishingPage, page, ctx, web);

            web.AddPublishingPage(page.FileName, page.Layout, page.Title, false); //DO NOT Publish here or it will fail if library doesn't enable Minor versions (PnP bug)

            publishingPage = web.GetPublishingPage(page.FileName + ".aspx");

            Microsoft.SharePoint.Client.File pageFile = publishingPage.ListItem.File;
            pageFile.CheckOut();

            if (page.Properties != null && page.Properties.Count > 0)
            {
                ctx.Load(pageFile, p => p.Name, p => p.CheckOutType); //need these values in SetFileProperties
                ctx.ExecuteQuery();
                pageFile.SetFileProperties(page.Properties, false);
            }

            if (page.WebParts != null && page.WebParts.Count > 0)
            {
                Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager mgr = pageFile.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);

                ctx.Load(mgr);
                ctx.ExecuteQuery();

                AddWebpartsToPublishingPage(page, ctx, mgr);
            }

            List pagesLibrary = publishingPage.ListItem.ParentList;
            ctx.Load(pagesLibrary);
            ctx.ExecuteQueryRetry();

            ListItem pageItem = publishingPage.ListItem;
            web.Context.Load(pageItem, p => p.File.CheckOutType);
            web.Context.ExecuteQueryRetry();            

            if (pageItem.File.CheckOutType != CheckOutType.None)
            {
                pageItem.File.CheckIn(String.Empty, CheckinType.MajorCheckIn);
            }

            if (page.Publish && pagesLibrary.EnableMinorVersions)
            {
                pageItem.File.Publish(String.Empty);
                if (pagesLibrary.EnableModeration)
                {
                    pageItem.File.Approve(String.Empty);
                }
            }


            if (page.WelcomePage)
            {
                SetWelcomePage(web, pageFile);
            }

            ctx.ExecuteQuery();
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:60,代码来源:PageHelper.cs

示例10: SPOWebPipeBind

 public SPOWebPipeBind()
 {
     _id = Guid.Empty;
     _url = string.Empty;
     _spOnlineWeb = null;
     _web = null;
 }
开发者ID:JohnKozell,项目名称:PnP,代码行数:7,代码来源:SPOWebPipeBind.cs

示例11: RemovePublishingPage

        private static void RemovePublishingPage(SPPublishing.PublishingPage publishingPage, PublishingPage page, ClientContext ctx, Web web)
        {
            if (publishingPage != null && publishingPage.ServerObjectIsNull.Value == false)
            {
                if (!web.IsPropertyAvailable("RootFolder"))
                {
                    web.Context.Load(web.RootFolder);
                    web.Context.ExecuteQueryRetry();
                }

                if (page.Overwrite)
                {
                    if (page.WelcomePage && web.RootFolder.WelcomePage.Contains(page.FileName + ".aspx"))
                    {
                        //set the welcome page to a Temp page to allow remove the page
                        web.RootFolder.WelcomePage = "home.aspx";
                        web.RootFolder.Update();
                        web.Update();

                        ctx.Load(publishingPage);
                        ctx.ExecuteQuery();
                    }

                    publishingPage.ListItem.DeleteObject();
                    ctx.ExecuteQuery();
                }
                else
                {
                    return;
                }
            }
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:32,代码来源:PageHelper.cs

示例12: AddExtendedTokens

 public TokenParser AddExtendedTokens(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
 {
     using (var scope = new PnPMonitoredScope(this.Name))
     {
         var context = web.Context as ClientContext;
         foreach (var provider in template.Providers)
         {
             if (provider.Enabled)
             {
                 try
                 {
                     if (!string.IsNullOrEmpty(provider.Configuration))
                     {
                         provider.Configuration = parser.ParseString(provider.Configuration);
                     }
                     scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_tokenprovider_extensibility_callout__0_, provider.Assembly);
                     var _providedTokens = _extManager.ExecuteTokenProviderCallOut(context, provider, template);
                     if (_providedTokens != null)
                     {
                         foreach (var token in _providedTokens)
                         {
                             parser.AddToken(token);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_tokenprovider_callout_failed___0_____1_, ex.Message, ex.StackTrace);
                     throw;
                 }
             }
         }
         return parser;
     }
 }
开发者ID:skybow,项目名称:PnP-Sites-Core,代码行数:35,代码来源:ObjectExtensibilityProviders.cs

示例13: SPOWeb

        public SPOWeb(Web web)
        {
            _web = web;

            //if (web.IsObjectPropertyInstantiated("AvailableFields"))
            //    AvailableFields = web.AvailableFields;

            //if (web.IsPropertyAvailable("EffectiveBasePermissions"))
            //    EffectiveBasePermissions = web.EffectiveBasePermissions;

            //if (web.IsObjectPropertyInstantiated("Features"))
            //    Features = web.Features;

            //if (web.IsObjectPropertyInstantiated("Fields"))
            //    Fields = web.Fields;

            //if (web.IsObjectPropertyInstantiated("ListTemplates"))
            //    ListTemplates = web.ListTemplates;

            //if (web.IsObjectPropertyInstantiated("Navigation"))
            //    Navigation = web.Navigation;

            //if (web.IsObjectPropertyInstantiated("RootFolder"))
            //    RootFolder = web.RootFolder;

            //if (web.IsObjectPropertyInstantiated("SiteGroups"))
            //    SiteGroups = web.SiteGroups;

            //if (web.IsObjectPropertyInstantiated("SiteUserInfoList"))
            //    SiteUserInfoList = web.SiteUserInfoList;

            //if (web.IsObjectPropertyInstantiated("SiteUsers"))
            //    SiteUsers = web.SiteUsers;
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:34,代码来源:SPOWeb.cs

示例14: Main

    static void Main() {

      Console.WriteLine("Adding Team Site Content");
      Console.WriteLine();

      clientContext = new ClientContext(siteUrl);

      site = clientContext.Web;
      clientContext.Load(site);      
      clientContext.ExecuteQuery();


      WingtipContentGenerator.CreateProductCategoriesTermset();
      WingtipContentGenerator.CreateProductsLists();

      Console.WriteLine();
      Console.WriteLine("The program has finsihed. Press ENTER to close this window");
      Console.WriteLine();
      Console.ReadLine();






      clientContext.ExecuteQuery();

    }
开发者ID:chrissimusokwe,项目名称:TrainingContent,代码行数:28,代码来源:Program.cs

示例15: Delete

        private void Delete(Web web)
        {
            if (!base.ShouldProcess(Identity.ToString()))
                return;

            var ctx = base.Context;
            if (!web.IsObjectPropertyInstantiated("Webs"))
            {
                ctx.Load(web.Webs);
                ctx.ExecuteQuery();
            }
            if (web.Webs.Count > 0)
            {
                foreach (Web childWeb in web.Webs)
                {
                    Delete(childWeb);
                }
                if (web.Webs.Count == 0)
                {
                    web.DeleteObject();
                    web.Context.ExecuteQuery();
                }
            }
            else
            {
                web.DeleteObject();
                web.Context.ExecuteQuery();
            }
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:29,代码来源:RemoveSPOWeb.cs


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