예제 #1
0
 public ActionResult IndexFilterPOST(WorkflowIndexViewModel model)
 {
     return(RedirectToAction("Index", new RouteValueDictionary {
         { "Options.Filter", model.Options.Filter },
         { "Options.OrderBy", model.Options.OrderBy }
     }));
 }
예제 #2
0
        public async Task <ActionResult> SearchResult(WorkflowIndexViewModel data)
        {
            if (data.queries == null)
            {
                return(View("Index", data));
            }
            else
            {
                var postTask = await client.PostAsJsonAsync("/api/Workflow/Search", data);

                var UserResult = await postTask.Content.ReadAsAsync <WorkflowSearchViewModel>();

                return(Json(UserResult, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public async Task <IActionResult> BulkEdit(WorkflowBulkAction bulkAction, PagerParameters pagerParameters, int workflowTypeId)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows))
            {
                return(Unauthorized());
            }

            var viewModel = new WorkflowIndexViewModel {
                Workflows = new List <WorkflowEntry>()
            };

            if (!(await TryUpdateModelAsync(viewModel)))
            {
                return(View(viewModel));
            }

            var checkedEntries = viewModel.Workflows.Where(t => t.IsChecked);

            switch (bulkAction)
            {
            case WorkflowBulkAction.None:
                break;

            case WorkflowBulkAction.Delete:
                foreach (var entry in checkedEntries)
                {
                    var workflow = await _workflowStore.GetAsync(entry.Id);

                    if (workflow != null)
                    {
                        await _workflowStore.DeleteAsync(workflow);

                        _notifier.Success(T["Workflow {0} has been deleted.", workflow.WorkflowId]);
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(RedirectToAction("Index", new { workflowTypeId, page = pagerParameters.Page, pageSize = pagerParameters.PageSize }));
        }
예제 #4
0
        public new async Task <ActionResult> View(string comp_id, string wflw_id)
        {
            if (comp_id != null && wflw_id != null)
            {
                WFModel model    = new WFModel();
                var     postTask = await client.GetAsync("/api/Workflow/View/?comp_id=" + comp_id + "&wflw_id=" + wflw_id);

                model = await postTask.Content.ReadAsAsync <WFModel>();

                if (model != null)
                {
                    return(View("View", model));
                }
                else
                {
                    WorkflowIndexViewModel data = new WorkflowIndexViewModel();
                    ViewBag.Error = "No Workflow Found !";
                    return(View("Index", data));
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
예제 #5
0
        public async Task <IActionResult> Index(int workflowTypeId, PagerParameters pagerParameters, string returnUrl = null)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows))
            {
                return(Unauthorized());
            }

            if (!Url.IsLocalUrl(returnUrl))
            {
                returnUrl = Url.Action(nameof(Index), "WorkflowType");
            }

            var workflowType = await _workflowTypeStore.GetAsync(workflowTypeId);

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var count = await _workflowStore.CountAsync(workflowType.WorkflowTypeId);

            var pager   = new Pager(pagerParameters, siteSettings.PageSize);
            var records = await _workflowStore.ListAsync(workflowType.WorkflowTypeId, pager.GetStartIndex(), pager.PageSize);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count);

            var viewModel = new WorkflowIndexViewModel
            {
                WorkflowType = workflowType,
                Workflows    = records.Select(x => new WorkflowEntry
                {
                    Workflow = x,
                    Id       = x.Id
                }).ToList(),
                Pager     = pagerShape,
                ReturnUrl = returnUrl
            };

            return(View(viewModel));
        }
예제 #6
0
        public async Task <IActionResult> Index(int workflowTypeId, WorkflowIndexViewModel model, PagerParameters pagerParameters, string returnUrl = null)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows))
            {
                return(Forbid());
            }

            if (!Url.IsLocalUrl(returnUrl))
            {
                returnUrl = Url.Action(nameof(Index), "WorkflowType");
            }

            var workflowType = await _workflowTypeStore.GetAsync(workflowTypeId);

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var query = _session.Query <Workflow, WorkflowIndex>();

            query = query.Where(x => x.WorkflowTypeId == workflowType.WorkflowTypeId);

            switch (model.Options.Filter)
            {
            case WorkflowFilter.Finished:
                query = query.Where(x => x.WorkflowStatus == WorkflowStatus.Finished);
                break;

            case WorkflowFilter.Faulted:
                query = query.Where(x => x.WorkflowStatus == WorkflowStatus.Faulted);
                break;

            case WorkflowFilter.All:
            default:
                break;
            }

            switch (model.Options.OrderBy)
            {
            case WorkflowOrder.CreatedDesc:
                query = query.OrderByDescending(x => x.CreatedUtc);
                break;

            case WorkflowOrder.Created:
                query = query.OrderBy(x => x.CreatedUtc);
                break;

            default:
                query = query.OrderByDescending(x => x.CreatedUtc);
                break;
            }

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var routeData = new RouteData();

            routeData.Values.Add("Filter", model.Options.Filter);

            var pagerShape  = (await New.Pager(pager)).TotalItemCount(await query.CountAsync()).RouteData(routeData);
            var pageOfItems = await query.Skip(pager.GetStartIndex()).Take(pager.PageSize).ListAsync();

            var viewModel = new WorkflowIndexViewModel
            {
                WorkflowType = workflowType,
                Workflows    = pageOfItems.Select(x => new WorkflowEntry
                {
                    Workflow = x,
                    Id       = x.Id
                }).ToList(),
                Options   = model.Options,
                Pager     = pagerShape,
                ReturnUrl = returnUrl
            };

            model.Options.WorkflowsSorts = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Recently created"], Value = nameof(WorkflowOrder.CreatedDesc)
                },
                new SelectListItem()
                {
                    Text = S["Least recently created"], Value = nameof(WorkflowOrder.Created)
                }
            };

            model.Options.WorkflowsStatuses = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["All"], Value = nameof(WorkflowFilter.All)
                },
                new SelectListItem()
                {
                    Text = S["Faulted"], Value = nameof(WorkflowFilter.Faulted)
                },
                new SelectListItem()
                {
                    Text = S["Finished"], Value = nameof(WorkflowFilter.Finished)
                }
            };

            viewModel.Options.WorkflowsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(WorkflowBulkAction.Delete)
                }
            };

            return(View(viewModel));
        }
예제 #7
0
        public ActionResult Index()
        {
            WorkflowIndexViewModel model = new WorkflowIndexViewModel();

            return(View("Index", model));
        }