public IHttpActionResult PutProcessFilter(string process, int filterId, Filter filter)
        {
            try
            {
                if (filter == null)
                {
                    return BadRequest("Filter is null.");
                }

                filter.Id = filterId;
                filter.ProcessSystemName = process;
                FilterRepository.UpdateFilter(filter);

                return StatusCode(HttpStatusCode.NoContent);
            }
            catch (ArgumentException ex)
            {
                return BadRequest(ex.Message);
            }
            catch (ProcessNotFoundException)
            {
                return NotFound();
            }
            catch (FilterNotFoundException)
            {
                return NotFound();
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, LoggerSource, ex);
                return InternalServerError();
            }
        }
        public IHttpActionResult PostProcessFilter(string process, Filter filter)
        {
            if (filter == null)
            {
                return BadRequest("Filter is null.");
            }

            try
            {
                filter.ProcessSystemName = process;
                filter = FilterRepository.InsertFilter(filter);

                return CreatedAtRoute(FilterRouteName, new { filterId = filter.Id }, filter);
            }
            catch (ArgumentException ex)
            {
                return BadRequest(ex.Message);
            }
            catch (ProcessNotFoundException)
            {
                return NotFound();
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, LoggerSource, ex);
                return InternalServerError();
            }
        }
        public void GetProcessFilter_Returns_FilterMetadata()
        {
            // Arrange.
            var filter = new Filter();
            Mock.Arrange(() => _filterRepository.GetFilter(ProcessName, FilterId)).Returns(filter);

            var controller = CreateProcessController();

            // Act.
            var result = controller.GetProcessFilter(ProcessName, FilterId) as OkNegotiatedContentResult<Filter>;

            // Assert.
            Assert.IsNotNull(result);
            Assert.AreSame(filter, result.Content);
        }
        public IHttpActionResult GetMultiCrossRefValues(string process, int id, string field, int pageIndex, bool isSkipFilter, string filterString, Filter filter)
        {
            if (string.IsNullOrEmpty(process))
            {
                return BadRequest("Process name is required.");
            }          

            if (filterString.Contains(CReffFilterTemplate))
            {
                filterString = filterString.Replace(CReffFilterTemplate, "");
            }

            var totalRowCount = 0;
            int pageNumber = 0;

            try
            {
                var details = DynamicTypeManager.GetEditableRoot<IEditableRoot>(process, id);
                string fullName = string.Join(".", details.GetFullPropertyPath(field));
                PropertyInfo property = details.GetPropertyByFullName(fullName);
                var model = details.GetAncestor(property);

                MobileObservableCollection<IFilterDescriptor> filterList = new MobileObservableCollection<IFilterDescriptor>();

                //if (!string.IsNullOrWhiteSpace(skipItemList) && skipItemList != "0")
                //{
                //    var skipItemFilter = new FilterDescriptor(Constants.IdColumnName, FilterOperator.NotIn, skipItemList.Split('|'));
                //    filterList.Add(skipItemFilter);
                //}

                if (filter != null && !string.IsNullOrWhiteSpace(filter.FilterDefinition))
                {
                    filterList.Add(FilterDescriptor.FromJSON(filter.FilterDefinition));
                }
                
                if (!isSkipFilter)
                {
                    IEnumerable<IFilterDescriptor> crossRefFilters = DynamicTypeManager.GetCrossRefFilter(model, field);
                    if (crossRefFilters != null)
                    {
                        filterList.AddRange(crossRefFilters);
                    }
                }

                var itemList = DynamicTypeManager.GetCrossReferenceList(process, field,
                       null,
                       filterString,
                       10,
                       pageIndex,
                       FilterDescriptor.GetFilterExpression(filterList)
                   );

                totalRowCount = (int)itemList.GetType().GetProperty("TotalRowCount").GetValue(itemList);
                pageNumber = (int)itemList.GetType().GetProperty("PageNumber").GetValue(itemList);

                var result = MultiCrossRefResult.Create(itemList, property, totalRowCount, pageNumber);

                return this.Ok(result);
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, "ProcessController", ex);
                throw;
            }
        }
Exemple #5
0
        private ILayoutInfo GetAppliedLayout(Filter filter)
        {
            if (LayoutId != null)
            {
                var layout = LayoutManager.GetLayoutInfo(LayoutId.Value);
                if (layout == null)
                {
                    throw ErrorUtils.LayoutNotFound(LayoutId.Value);
                }

                return layout;
            }

            if (filter != null && filter.LayoutId.HasValue)
            {
                var layout = LayoutManager.GetLayoutInfo(filter.LayoutId.Value);
                if (layout != null)
                {
                    return layout;
                }
            }

            var defaultLayout = LayoutManager.GetCurrentUserDefaultLayout(ProcessName);
            if (defaultLayout == null)
            {
                throw ErrorUtils.DefaultLayoutNotFound(ProcessName);
            }

            return defaultLayout;
        }