示例#1
0
        public JsonResult Execute(long queryId)
        {
            var context    = new DataContext(false);
            var dataSvc    = new DataAccess(context);
            var queryModel = dataSvc.Get((int)ModelType.Query, queryId);

            ISQLObject sqlObj = _CreateQuery((QueryModel)queryModel);

            string sql = sqlObj.ToSQL();

            var dt = _db.ExecuteQuery(sql);

            //byte[] data = BinarySerializer.Serialize(dt);

            //var output = new QueryOutput()
            //{
            //    QueryId = queryId,
            //    Data = data,
            //    TotalRows = dt.Rows.Count(),
            //    ResultType = (int)QueryResultType.Success
            //};

            //var queryOutputRepos = new EFDataRepository<Domain.QueryOutput>(context);

            //queryOutputRepos.AddOrUpdate(output);


            var vm = new TableContainerModel()
            {
                ShowFilters = false,
                IsEditable  = false,
                Title       = "Results"
            };

            vm.Children = dt.Rows.Select(
                r => new Model()
            {
                Properties = r.Values.Select((v, i) =>
                                             new ModelProperty()
                {
                    Type  = DataType.String,
                    Value = v,
                    Name  = dt.Columns[i]
                }
                                             ).ToDictionary(p => p.Name, p => p)
            }
                ).Cast <IModel>().ToList();

            vm.Properties = vm.Properties.Append(
                dt.Columns.Select(c => new ModelProperty()
            {
                Name = c, Type = DataType.String
            })
                .ToDictionary(c => c.Name, c => c).ToArray()
                );

            System.Threading.Thread.Sleep(2000);

            return(Json(vm, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        //GET: Project
        #region actions
        public ActionResult Index()
        {
            var context     = new DataContext(false);
            var dataSvc     = new DataAccess(context);
            var vmContainer = dataSvc.CreateContainerModel((int)ModelType.Report);

            //TODO should go in JSON template + loaded from file
            var tableContainer = new TableContainerModel(vmContainer);

            _UpdateContainer(tableContainer);

            var vmPage = new PageModel()
            {
                //Test = new DataEntity() {
                //    Properties = new Dictionary<string, DataProperty>()
                //    {
                //        { "Test1", new DataProperty() { Name = "Test1", Type=DataType.Number, Value=2222} }
                //    }
                //},
                Title        = "Reports",
                CategoryName = "Report",
                Children     = new List <IModel>()
                {
                    tableContainer
                }
            };

            return(View(vmPage));
        }
示例#3
0
        //GET: Project
        #region actions
        public ActionResult Index()
        {
            var context     = new DataContext(false);
            var dataSvc     = new DataAccess(context);
            var vmContainer = dataSvc.CreateContainerModel((int)ModelType.Query);

            //TODO should go in JSON template + loaded from file
            var tableContainer = new TableContainerModel(vmContainer);

            _UpdateContainer(tableContainer);

            var vmPage = new PageModel()
            {
                Title        = "Queries",
                CategoryName = "Query",
                Children     = new List <IModel>()
                {
                    tableContainer
                }
            };

            return(View(vmPage));
        }