Exemple #1
0
 protected override void Initialize(HttpControllerContext controllerContext)
 {
     base.Initialize(controllerContext);
     SharedContextResolver = GetService <IContextResolver>();
     SharedContextResolver.AttachRealBlock(() => BlockOfRequest);
     SharedContextResolver.AttachBlockContext(() => BlockOfRequest?.Context);
 }
Exemple #2
0
        public QueryRunDto DebugStream(int appId, int id, string from, string @out, int top = 25)
        {
            // todo: the first two lines should be in the QueryApi backend, but ATM that's still in EAV and is missing some objects
            var block  = SharedContextResolver.RealBlockRequired();
            var config = GetService <AppConfigDelegate>().Init(Log).GetConfigProviderForModule(block.Context, block.App, block);

            return(GetService <QueryApi>().Init(appId, Log).DebugStream(appId, id, top, config, @from, @out));
        }
Exemple #3
0
        public HttpResponseMessage GetContentBlockData()
        {
            Log.Add("get content block data");
            // Important note: we are NOT supporting url-view switch at the moment for this
            // reason is, that this kind of data-access is fairly special
            // and not recommended for future use cases, where we have the query etc.
            // IF you want to support View-switching in this, do a deep review w/2dm first!
            // - note that it's really not needed, as you can always use a query or something similar instead
            // - not also that if ever you do support view switching, you will need to ensure security checks

            var dataHandler = new AppContentJsonForInstance();
            var block       = SharedContextResolver.RealBlockRequired();
            // must access engine to ensure pre-processing of data has happened,
            // especially if the cshtml contains a override void CustomizeData()
            var engine = block.BlockBuilder.GetEngine(Purpose.PublishData);

            engine.CustomizeData();

            var    dataSource = block.Data;
            string json;

            if (dataSource.Publish.Enabled)
            {
                var publishedStreams = dataSource.Publish.Streams;
                var streamList       = publishedStreams.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                json = dataHandler.GenerateJson(dataSource, streamList, block.Context.UserMayEdit);
            }
            else
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    ReasonPhrase = dataHandler.GeneratePleaseEnableDataError(ActiveModule.ModuleID)
                });
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(json, Encoding.UTF8, "application/json");
            return(response);
        }
Exemple #4
0
        private void TryToAttachAppFromUrlParams()
        {
            var wrapLog = Log.Call();
            var found   = false;

            try
            {
                var routeAppPath = Route.AppPathOrNull(Request.GetRouteData());
                var appId        = SharedContextResolver.AppOrNull(routeAppPath)?.AppState.AppId ?? Eav.Constants.NullId;

                if (appId != Eav.Constants.NullId)
                {
                    //var appId = AppFinder.GetAppIdFromPath(routeAppPath).AppId;
                    // Look up if page publishing is enabled - if module context is not available, always false
                    Log.Add($"AppId: {appId}");
                    var app = Factory.App(appId, false, parentLog: Log);
                    DynCode.LateAttachApp(app);
                    found = true;
                }
            } catch { /* ignore */ }

            wrapLog(found.ToString());
        }
Exemple #5
0
	    public QueryRunDto Run(int appId, int id)
        {
            var block = SharedContextResolver.RealBlockRequired();
            var config = GetService<AppConfigDelegate>().Init(Log).GetConfigProviderForModule(block.Context, block.App, block);
            return GetService<QueryApi>().Init(appId, Log).Run(appId, id, config);
        }