Exemplo n.º 1
0
        public ActionResult SaveQuery(int databaseId, string nodes, string id = null)
        {
            if (id == null)
            {
                id = Guid.NewGuid().ToString("N");
            }

            var data = new NodeCacheObject()
            {
                DatabaseId = databaseId, Nodes = nodes
            };

            _cache.Set(id, data, DateTime.Now.AddHours(1));

            return(Json(new { id = id }));
        }
Exemplo n.º 2
0
        public ActionResult ExportQuery(string id, string nodeId, int?startRow = null, int?rowCount = null)
        {
            NodeCacheObject cacheObj = null;

            if (_cache.TryGetValue(id, out cacheObj) == false)
            {
                return(NotFound("Nodes were not found, please store the nodes by calling POST /api/Nodes"));
            }

            var connection = GetConnection(cacheObj.DatabaseId);

            if (CanUserAccessDatabase(connection))
            {
                var data = _dbMgr.GetData(connection, cacheObj.Nodes, nodeId, startRow, rowCount);

                var result = this.convertManager.ToExcel(data);

                return(File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "export.xlsx"));
            }

            return(NotFound());
        }
Exemplo n.º 3
0
        public ActionResult RunQuery(string id, string nodeId, int?startRow = null, int?rowCount = null)
        {
            NodeCacheObject cacheObj = null;

            if (_cache.TryGetValue(id, out cacheObj) == false)
            {
                return(NotFound("Nodes were not found, please store the nodes by calling POST /api/Nodes"));
            }

            var connection = GetConnection(cacheObj.DatabaseId);

            if (CanUserAccessDatabase(connection))
            {
                var data = _dbMgr.GetData(connection, cacheObj.Nodes, nodeId, startRow, rowCount);

                return(Json(data));
            }
            else
            {
                return(NotFound());
            }
        }