Exemplo n.º 1
0
        public HttpResponseMessage PostWorkflow(WorkFlowViewModel viewModel)
        {
            InsertWorkflowRequest request = new InsertWorkflowRequest()
            {
                WorkflowViewModel = viewModel,
                AccountId         = this.AccountId,
                RequestedBy       = this.UserId,
                RoleId            = this.RoleId
            };
            InsertWorkflowResponse response = workflowService.InsertWorkflow(request);

            return(Request.BuildResponse(response));
        }
Exemplo n.º 2
0
        public JsonResult AddWorkflow(string workflowViewModel)
        {
            var settings = new JsonSerializerSettings();

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

            /*exclude send campaign actions */
            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;
                    }
                }
            });
            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 inserting workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAt);
                    }
                    else if (((WorkflowTimerActionViewModel)a.Action).RunAtTime != null)
                    {
                        Logger.Current.Informational("workflow set timer action time zone(when inserting workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAtTime);
                    }
                }
            });
            viewModel = ProcessWorkflowFromClient(viewModel, viewModel);
            InsertWorkflowRequest request = new InsertWorkflowRequest()
            {
                WorkflowViewModel = viewModel,
                AccountId         = this.Identity.ToAccountID(),
                RequestedBy       = this.Identity.ToUserID(),
                RoleId            = this.Identity.ToRoleID()
            };

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