コード例 #1
0
        public ActionResult PublishSubmitEvent(int id, Guid workflowInstanceId, string spHostUrl)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
            using (var clientContext = spContext.CreateUserClientContextForSPAppWeb())
            {
                var service = new PartSuppliersService(clientContext);
                service.PublishCustomEvent(workflowInstanceId, "Submit for Approval", "");
                
                // Wait until workflow user status changed
                WorkflowInstance instance;
                do
                {
                    Thread.Sleep(1000);
                    instance = service.GetWorkflowInstance(workflowInstanceId);
                }
                while (instance.UserStatus == "Wait for Submit");
            }
            TempData["Message"] = "Successfully Submitted For Approval!";


            return RedirectToAction("Details", new { id = id, SPHostUrl = spHostUrl });
        }