Exemplo n.º 1
0
        public ActionResult CopyWorkFlow(short WorkflowID)
        {
            GetWorkflowResponse response = workflowService.CopyWorkFlow(new GetWorkflowRequest()
            {
                WorkflowID  = WorkflowID,
                AccountId   = this.Identity.ToAccountID(),
                RequestedBy = this.Identity.ToUserID(),
                RoleId      = this.Identity.ToRoleID()
            });

            ViewBag.ParentID = 0;
            if (response.WorkflowViewModel != null && response.WorkflowViewModel.WorkflowActions != null)
            {
                response.WorkflowViewModel.WorkflowActions.Each(a =>
                {
                    if (a.WorkflowActionTypeID == WorkflowActionType.SetTimer)
                    {
                        if (((WorkflowTimerActionViewModel)a.Action).RunAt != null)
                        {
                            Logger.Current.Informational("workflow  set timer action time zone(when retriving workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAt.Value.ToUtcBrowserDatetime());
                            ((WorkflowTimerActionViewModel)a.Action).RunAt = ((WorkflowTimerActionViewModel)a.Action).RunAt.Value.ToUtcBrowserDatetime();
                        }
                        else if (((WorkflowTimerActionViewModel)a.Action).RunAtTime != null)
                        {
                            Logger.Current.Informational("workflow set timer action time zone(when retriving workflow in controller): " + ((WorkflowTimerActionViewModel)a.Action).RunAtTime.Value.ToUtcBrowserDatetime());
                            DateTime value = ((WorkflowTimerActionViewModel)a.Action).RunAtTime.Value.ToUtcBrowserDatetime();
                            ((WorkflowTimerActionViewModel)a.Action).RunAtTime = value;
                        }
                        else if (((WorkflowTimerActionViewModel)a.Action).StartDate != null && ((WorkflowTimerActionViewModel)a.Action).EndDate != null)
                        {
                            ((WorkflowTimerActionViewModel)a.Action).StartDate = ((WorkflowTimerActionViewModel)a.Action).StartDate.Value.ToUtcBrowserDatetime();
                            ((WorkflowTimerActionViewModel)a.Action).EndDate   = ((WorkflowTimerActionViewModel)a.Action).EndDate.Value.ToUtcBrowserDatetime();
                        }
                        if (((WorkflowTimerActionViewModel)a.Action).RunOnDate != null)
                        {
                            ((WorkflowTimerActionViewModel)a.Action).RunOnDate = ((WorkflowTimerActionViewModel)a.Action).RunOnDate.Value.ToUserUtcDateTime();
                        }
                    }
                });
            }
            var viewModel = ProcessWorkflowFromServer(response.WorkflowViewModel, response.WorkflowViewModel);

            ViewBag.DateFormat = this.Identity.ToDateFormat();
            ViewBag.SenderName = this.Identity.ToFirstName() + " " + this.Identity.ToLastName();
            return(View("AddEditWorkflow", viewModel));
        }