Example #1
0
        public void PerformSiteModification(ClientContext ctx, SiteModifyRequest modifyRequest)
        {
            // Sleep 20 sec to show the challenge
            Thread.Sleep(20000);

            // Perform simple operation by adding new document lib to host web
            CreateDocLibrary(ctx, DateTime.Now.Ticks.ToString(), string.Format("Requested by {0}", modifyRequest.RequestorName));
        }
Example #2
0
        public void PerformSiteModification(ClientContext ctx, SiteModifyRequest modifyRequest)
        {
            // Sleep 10 sec to show the challenge
            Thread.Sleep(10000);

            // Perform simple operation by adding new document lib to host web
            CreateDocLibrary(ctx, Guid.NewGuid().ToString().Replace("-", ""), string.Format("Requested by {0}", modifyRequest.RequestorName));
        }
Example #3
0
        public void PerformSiteModification(ClientContext ctx, SiteModifyRequest modifyRequest)
        {
            // Sleep 10 sec to show the challenge
            Thread.Sleep(10000);

            // Perform simple operation by adding new document lib to host web
            CreateDocLibrary(ctx, Guid.NewGuid().ToString().Replace("-", ""), string.Format("Requested by {0}", modifyRequest.RequestorName));
        }
Example #4
0
        public void PerformSiteModification(ClientContext ctx, SiteModifyRequest modifyRequest)
        {
            // Sleep 20 sec to show the challenge
            Thread.Sleep(20000);

            // Perform simple operation by adding new document lib to host web
            CreateDocLibrary(ctx, DateTime.Now.Ticks.ToString(), string.Format("Requested by {0}", modifyRequest.RequestorName));
        }
Example #5
0
        static void Main(string[] args)
        {
            string requestorName = "Keyser Söze";
            string siteUrl = "https://vesaj.sharepoint.com/sites/dev";

            SiteModifyRequest request = new SiteModifyRequest() { RequestorName = requestorName, SiteUrl = siteUrl };

            new SiteManager().AddAsyncOperationRequestToQueue(request,
                                                              ConfigurationManager.AppSettings["StorageConnectionString"]);
        }
Example #6
0
        /// <summary>
        /// Used to add new message to storage queue for processing
        /// </summary>
        /// <param name="modifyRequest">Request object with needed details</param>
        /// <param name="storageConnectionString">Storage connection string</param>
        public void AddAsyncOperationRequestToQueue(SiteModifyRequest modifyRequest, 
                                                    string storageConnectionString)
        {
            CloudStorageAccount storageAccount =
                                CloudStorageAccount.Parse(storageConnectionString);

            // Get queue... create if does not exist.
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue queue = queueClient.GetQueueReference(SiteManager.StorageQueueName);
            queue.CreateIfNotExists();

            // Add entry to queue
            queue.AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(modifyRequest)));
        }
Example #7
0
        /// <summary>
        /// Used to add new message to storage queue for processing
        /// </summary>
        /// <param name="modifyRequest">Request object with needed details</param>
        /// <param name="storageConnectionString">Storage connection string</param>
        public void AddAsyncOperationRequestToQueue(SiteModifyRequest modifyRequest,
                                                    string storageConnectionString)
        {
            CloudStorageAccount storageAccount =
                CloudStorageAccount.Parse(storageConnectionString);

            // Get queue... create if does not exist.
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue       queue       = queueClient.GetQueueReference(SiteManager.StorageQueueName);

            queue.CreateIfNotExists();

            // Add entry to queue
            queue.AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(modifyRequest)));
        }
Example #8
0
        protected void btnSync_Click(object sender, EventArgs e)
        {

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                //get the current user to be set for the process
                var currUser = clientContext.Web.CurrentUser;
                clientContext.Load(currUser);
                clientContext.ExecuteQuery();

                // Add request to the process queue
                SiteModifyRequest request = new SiteModifyRequest() { RequestorName = currUser.Title, SiteUrl = Page.Request["SPHostUrl"] };
                new SiteManager().PerformSiteModification(clientContext, request);

                // Change active view
                processViews.ActiveViewIndex = 1;
                lblStatus.Text = "Synchronous operation completed.";
            }
        }
Example #9
0
        protected void btnAsync_Click(object sender, EventArgs e)
        {

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                //get the current user to be set for the process
                var currUser = clientContext.Web.CurrentUser;
                clientContext.Load(currUser);
                clientContext.ExecuteQuery();

                // Add request to queue
                SiteModifyRequest request = new SiteModifyRequest() { RequestorName = currUser.Title, SiteUrl = Page.Request["SPHostUrl"] };
                new SiteManager().AddAsyncOperationRequestToQueue(request,
                                                                  ConfigurationManager.AppSettings["StorageConnectionString"]);

                // Change active view
                processViews.ActiveViewIndex = 1;
                lblStatus.Text = "Asynchronous operation started, end user can continue.";
            }
        }