/// <summary>Snippet for UpdateWorkflowAsync</summary>
        public async Task UpdateWorkflowRequestObjectAsync()
        {
            // Snippet: UpdateWorkflowAsync(UpdateWorkflowRequest, CallSettings)
            // Additional: UpdateWorkflowAsync(UpdateWorkflowRequest, CancellationToken)
            // Create client
            WorkflowsClient workflowsClient = await WorkflowsClient.CreateAsync();

            // Initialize request argument(s)
            UpdateWorkflowRequest request = new UpdateWorkflowRequest
            {
                Workflow   = new Workflow(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Operation <Workflow, OperationMetadata> response = await workflowsClient.UpdateWorkflowAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Workflow, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Workflow result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Workflow, OperationMetadata> retrievedResponse = await workflowsClient.PollOnceUpdateWorkflowAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Workflow retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Ejemplo n.º 2
0
        public HttpResponseMessage PutWorkflow(WorkFlowViewModel viewModel)
        {
            UpdateWorkflowRequest request = new UpdateWorkflowRequest()
            {
                WorkflowViewModel = viewModel,
                AccountId         = this.AccountId,
                RequestedBy       = this.UserId,
                RoleId            = this.RoleId
            };
            UpdateWorkflowResponse response = workflowService.UpdateWorkflow(request);

            return(Request.BuildResponse(response));
        }
Ejemplo n.º 3
0
        public JsonResult SaveSettings(string workflowViewModel)
        {
            WorkFlowViewModel     viewModel = JsonConvert.DeserializeObject <WorkFlowViewModel>(workflowViewModel);
            UpdateWorkflowRequest request   = new UpdateWorkflowRequest()
            {
                WorkflowViewModel = viewModel,
                AccountId         = this.Identity.ToAccountID(),
                RequestedBy       = this.Identity.ToUserID(),
                RoleId            = this.Identity.ToRoleID()
            };

            workflowService.UpdateWorkflow(request);
            return(Json(new
            {
                success = true,
                response = ""
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public JsonResult UpdateWorkflow(string workflowViewModel)
        {
            var settings  = new JsonSerializerSettings();
            var accountId = this.Identity.ToAccountID();

            settings.Converters.Add(new BaseWorkflowActionConverter());
            settings.NullValueHandling = NullValueHandling.Ignore;
            var viewModel = JsonConvert.DeserializeObject <WorkFlowViewModel>(workflowViewModel, settings);

            viewModel.WorkflowActions.Each(a => {
                if (a.WorkflowActionTypeID == WorkflowActionType.SetTimer)
                {
                    if (((WorkflowTimerActionViewModel)a.Action).RunAtDateTime != null)
                    {
                        ((WorkflowTimerActionViewModel)a.Action).RunAt = ((WorkflowTimerActionViewModel)a.Action).RunAtDateTime;
                    }
                    else if (((WorkflowTimerActionViewModel)a.Action).RunAtTimeDateTime != null)
                    {
                        ((WorkflowTimerActionViewModel)a.Action).RunAtTime = ((WorkflowTimerActionViewModel)a.Action).RunAtTimeDateTime;
                    }

                    if (((WorkflowTimerActionViewModel)a.Action).RunOnDate.HasValue)
                    {
                        ((WorkflowTimerActionViewModel)a.Action).RunOnDate = ((WorkflowTimerActionViewModel)a.Action).RunOnDate.Value.Date.ToUserDateTime().ToUtc();
                    }
                }
            });
            viewModel.WorkflowActions.Each(a => {
                if (a.WorkflowActionTypeID == WorkflowActionType.SetTimer)
                {
                    if (((WorkflowTimerActionViewModel)a.Action).RunAt != null)
                    {
                        Logger.Current.Informational("workflow  set timer action time zone(when Updating workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAt);
                    }
                    else if (((WorkflowTimerActionViewModel)a.Action).RunAtTime != null)
                    {
                        Logger.Current.Informational("workflow set timer action time zone(when Updating workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAtTime);
                    }
                }
            });
            var serverViewModel = workflowService.GetWorkFlow(new GetWorkflowRequest()
            {
                WorkflowID = viewModel.WorkflowID,
                AccountId  = accountId
            }).WorkflowViewModel;

            viewModel = ProcessWorkflowFromClient(viewModel, serverViewModel);
            UpdateWorkflowRequest request = new UpdateWorkflowRequest()
            {
                WorkflowViewModel = viewModel,
                AccountId         = this.Identity.ToAccountID(),
                RequestedBy       = this.Identity.ToUserID(),
                RoleId            = this.Identity.ToRoleID()
            };

            workflowService.UpdateWorkflow(request);
            return(Json(new
            {
                success = true,
                response = ""
            }, JsonRequestBehavior.AllowGet));
        }