상속: BaseQueryRequest
 public static UserQueryEntity ToUserQuery(QueryRequest request)
 {
     return request.ToUserQuery(
         DynamicQueryManager.Current.QueryDescription(request.QueryName),
         QueryLogic.GetQueryEntity(request.QueryName),
         FindOptions.DefaultPagination,
         withoutFilters: false /*Implement Simple Filter Builder*/);
 }
예제 #2
0
        public ActionResult ToExcelPlain(QueryRequest request)
        {
            if (!Finder.IsFindable(request.QueryName))
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(request.QueryName));

            ResultTable queryResult = DynamicQueryManager.Current.ExecuteQuery(request);
            byte[] binaryFile = PlainExcelGenerator.WritePlainExcel(queryResult);

            return File(binaryFile, MimeType.FromExtension(".xlsx"), Finder.ResolveWebQueryName(request.QueryName) + ".xlsx");
        }
예제 #3
0
        public ActionResult ExcelReport(QueryRequest request, Lite<ExcelReportEntity> excelReport)
        {
            if (!Finder.IsFindable(request.QueryName))
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(request.QueryName));

            byte[] file = ExcelLogic.ExecuteExcelReport(excelReport, request);

            return File(file, MimeType.FromExtension(".xlsx"), Finder.ResolveWebQueryName(request.QueryName) + "-" + TimeZoneManager.Now.ToString("yyyyMMdd-HHmmss") + ".xlsx");
            //Known Bug in IE: When the file dialog is shown, if Open is chosen the Excel will be broken as a result of IE automatically adding [1] to the name. 
            //There's not workaround for this, so either click on Save instead of Open, or use Firefox or Chrome
        }
예제 #4
0
        public static byte[] ExecuteExcelReport(Lite<ExcelReportEntity> excelReport, QueryRequest request)
        {
            ResultTable queryResult = DynamicQueryManager.Current.ExecuteQuery(request);

            ExcelReportEntity report = excelReport.RetrieveAndForget();
            string extension = Path.GetExtension(report.File.FileName);
            if (extension != ".xlsx")
                throw new ApplicationException(ExcelMessage.ExcelTemplateMustHaveExtensionXLSXandCurrentOneHas0.NiceToString().FormatWith(extension));

            return ExcelGenerator.WriteDataInExcelFile(queryResult, report.File.BinaryFile);
        }
        public ActionResult Create(QueryRequest request)
        {
            if (!Finder.IsFindable(request.QueryName))
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(request.QueryName));

            var userQuery = ToUserQuery(request);

            userQuery.Owner = UserEntity.Current.ToLite();

            return Navigator.NormalPage(this, userQuery);
        }
예제 #6
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            QueryRequest qr = new QueryRequest();

            NameValueCollection parameters = controllerContext.HttpContext.Request.Params;

            if (parameters.AllKeys.Any(name => !name.HasText()))
                throw new Exception("Incorrect URL: " + controllerContext.HttpContext.Request.Url.ToString());

            string webQueryName = "";
            object rawValue = bindingContext.ValueProvider.GetValue("webQueryName")?.RawValue;
            if (rawValue.GetType() == typeof(string[]))
                webQueryName = ((string[])rawValue)[0];
            else
                webQueryName = (string)rawValue;

            if (!webQueryName.HasText())
                throw new InvalidOperationException("webQueryName not provided");

            qr.QueryName = Finder.ResolveQueryName(webQueryName);

            if (parameters.AllKeys.Contains("queryUrl"))
                qr.QueryUrl = parameters["queryUrl"];

            QueryDescription queryDescription = DynamicQueryManager.Current.QueryDescription(qr.QueryName);

            qr.Filters = ExtractFilterOptions(controllerContext.HttpContext, queryDescription, canAggregate: false);
            qr.Orders = ExtractOrderOptions(controllerContext.HttpContext, queryDescription, canAggregate: false);
            qr.Columns = ExtractColumnsOptions(controllerContext.HttpContext, queryDescription, canAggregate: false);

            if (parameters.AllKeys.Contains("pagination"))
            {
                switch (parameters["pagination"].ToEnum<PaginationMode>())
                {
                    case PaginationMode.All:
                        qr.Pagination = new Pagination.All();
                        break;
                    case PaginationMode.Firsts:
                        qr.Pagination = new Pagination.Firsts(
                            parameters.AllKeys.Contains("elems") ? int.Parse(parameters["elems"]) : Pagination.Firsts.DefaultTopElements);
                        break;
                    case PaginationMode.Paginate:
                        qr.Pagination = new Pagination.Paginate(
                            parameters.AllKeys.Contains("elems") ? int.Parse(parameters["elems"]) : Pagination.Paginate.DefaultElementsPerPage,
                            parameters.AllKeys.Contains("page") ? int.Parse(parameters["page"]) : 1);
                        break;
                    default:
                        break;
                }
            }

            return qr;
        }
예제 #7
0
        public static QueryRequest ToQueryRequest(this UserQueryEntity userQuery)
        {
            var qr = new QueryRequest();

            qr.QueryName = userQuery.Query.ToQueryName();

            if (!userQuery.WithoutFilters)
            {
                qr.Filters = userQuery.Filters.Select(qf => 
                    new Filter(qf.Token.Token, qf.Operation, FilterValueConverter.Parse(qf.ValueString, qf.Token.Token.Type, qf.Operation.IsList()))).ToList();
            }

            qr.Columns = MergeColumns(userQuery);
            qr.Orders = userQuery.Orders.Select(qo => new Order(qo.Token.Token, qo.OrderType)).ToList();

            qr.Pagination = userQuery.GetPagination() ?? new Pagination.All();

            return qr;
        }
예제 #8
0
        public static byte[] ExecutePlainExcel(QueryRequest request)
        {
            ResultTable queryResult = DynamicQueryManager.Current.ExecuteQuery(request);

            return PlainExcelGenerator.WritePlainExcel(queryResult);
        }
예제 #9
0
 public PartialViewResult Search(QueryRequest queryRequest, bool allowSelection, bool navigate, bool showFooter, string prefix)
 {
     return Finder.SearchResults(this, queryRequest, allowSelection, navigate, showFooter, prefix);
 }
예제 #10
0
 public byte[] ExecutePlainExcel(QueryRequest request)
 {
     return Return(MethodInfo.GetCurrentMethod(),
         () => ExcelLogic.ExecutePlainExcel(request, QueryUtils.GetNiceName(request.QueryName)));
 }
예제 #11
0
 public byte[] ExecuteExcelReport(Lite<ExcelReportEntity> excelReport, QueryRequest request)
 {
     return Return(MethodInfo.GetCurrentMethod(),
         () => ExcelLogic.ExecuteExcelReport(excelReport, request));
 }
예제 #12
0
        public QueryRequest GetQueryRequest(bool updateSimpleFilters)
        {
            if (updateSimpleFilters)
                RefreshSimpleFilters();

            var request = new QueryRequest
            {
                QueryName = QueryName,
                Filters = FilterOptions.Select(f => f.ToFilter()).ToList(),
                Orders = OrderOptions.Select(o => o.ToOrder()).ToList(),
                Columns = gvResults.Columns.Select(gvc => ((SortGridViewColumnHeader)gvc.Header).RequestColumn).ToList(),
                Pagination = Pagination,
            };

            return request;
        }
예제 #13
0
 public byte[] ExecutePlainExcel(QueryRequest request)
 {
     return Return(MethodInfo.GetCurrentMethod(),
         () => ExcelLogic.ExecutePlainExcel(request));
 }