Exemplo n.º 1
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            var    spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
            string newWebUrl = string.Empty;

            using (ClientContext ctx = spContext.CreateUserClientContextForSPHost())
            {
                SharePointUser currentUser;
                ctx.Load(ctx.Web.CurrentUser);
                ctx.ExecuteQuery();

                var user = ctx.Web.CurrentUser;
                currentUser = new SharePointUser()
                {
                    Email = user.Email,
                    Login = user.LoginName,
                    Name  = user.Title
                };


                var siteRequestInfo = new SiteRequestInformation()
                {
                    Title       = this.txtTitle.Text,
                    Description = this.txtDescription.Text,
                    EnumStatus  = SiteRequestStatus.New,
                    Template    = "STS#0",
                    SiteOwner   = currentUser,
                };

                siteRequestInfo.Url = string.Format(@"{0}{1}", this.lblBasePath.Text, siteRequestInfo.Title);
                LabHelper _helper = new LabHelper();
                _helper.AddRequest(siteRequestInfo, ctx);
            }


            Response.Redirect(Page.Request["SPHostUrl"]);
        }
Exemplo n.º 2
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
            string newWebUrl = string.Empty;
            using (ClientContext ctx = spContext.CreateUserClientContextForSPHost())
            {

                SharePointUser currentUser;
                ctx.Load(ctx.Web.CurrentUser);
                ctx.ExecuteQuery();

                var user = ctx.Web.CurrentUser;
                currentUser = new SharePointUser()
                {
                    Email = user.Email,
                    Login = user.LoginName,
                    Name = user.Title
                };

                var siteRequestInfo = new SiteRequestInformation()
                {
                    Title = this.txtTitle.Text,
                    Description = this.txtDescription.Text,
                    EnumStatus = SiteRequestStatus.New,
                    Template = "STS#0",
                    SiteOwner = currentUser,

                };

                siteRequestInfo.Url = string.Format(@"{0}{1}", this.lblBasePath.Text, siteRequestInfo.Title);
                LabHelper _helper = new LabHelper();
                _helper.AddRequest(siteRequestInfo, ctx);
            }

            Response.Redirect(Page.Request["SPHostUrl"]);
        }