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)); }
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)); }
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)); }
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)); }
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"]); }
/// <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))); }
/// <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))); }
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."; } }
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."; } }