예제 #1
0
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            // Only display on admin pages
            if (!(context.Result is ViewResult || context.Result is PageResult) ||
                !AdminAttribute.IsApplied(context.HttpContext))
            {
                await next();

                return;
            }

            try {
                dynamic layout = await _layoutAccessor.GetLayoutAsync();

                layout.Zones["NavbarTop"].Add(
                    await _shapeFactory.New.DeploymentNavBar()
                    );
            } catch (Exception e) {
                _logger.LogError(e, "Failed to add DeploymentNavBar to Header Shapes");
            }

            await next();

            return;
        }
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            // Should only run on the front-end for a full view
            if ((context.Result is ViewResult || context.Result is PageResult) &&
                !AdminAttribute.IsApplied(context.HttpContext))
            {
                if (_scriptsCache == null)
                {
                    var settings = (await _siteService.GetSiteSettingsAsync()).As <CookiesSettings>();

                    //if (!string.IsNullOrWhiteSpace(settings?.ServicesScript))
                    //{
                    _scriptsCache = new HtmlString($"<script src=\"/TarteAuCitron.OrchardCore/Scripts/tarteaucitron.js\"></script>\n<script>tarteaucitron.init({{ \"privacyUrl\": \"{settings.PrivacyUrl}\", \"hashtag\": \"#tarteaucitron\", \"cookieName\": \"{settings.CookieName}\", \"orientation\": \"{settings.Orientation}\", \"showAlertSmall\": {settings.ShowAlertSmall.ToString().ToLower()}, \"cookieslist\": {settings.Cookieslist.ToString().ToLower()}, \"adblocker\": {settings.AdBlocker.ToString().ToLower()}, \"AcceptAllCta\" : {settings.AcceptAllCta.ToString().ToLower()}, \"highPrivacy\": {settings.HighPrivacy.ToString().ToLower()}, \"handleBrowserDNTRequest\": {settings.HandleBrowserDNTRequest.ToString().ToLower()}, \"removeCredit\": {settings.RemoveCredit.ToString().ToLower()}, \"moreInfoLink\": {settings.MoreInfoLink.ToString().ToLower()}, \"useExternalCss\": false, \"readmoreLink\": \"{settings.ReadMoreLink}\"}});</script>\n<script>{settings.ServicesScript}</script>");
                    //}
                }

                if (_scriptsCache != null)
                {
                    //_resourceManager.RegisterLink();
                    _resourceManager.RegisterHeadScript(_scriptsCache);
                }
            }

            await next.Invoke();
        }
예제 #3
0
        public async Task <ShapeBinding> GetShapeBindingAsync(string shapeType)
        {
            if (!AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                return(null);
            }

            var localTemplates = _previewTemplatesProvider.GetTemplates();

            if (localTemplates != null)
            {
                if (localTemplates.Templates.TryGetValue(shapeType, out var localTemplate))
                {
                    return(BuildShapeBinding(shapeType, localTemplate));
                }
            }

            if (_templatesDocument == null)
            {
                _templatesDocument = await _templatesManager.GetTemplatesDocumentAsync();
            }

            if (_templatesDocument.Templates.TryGetValue(shapeType, out var template))
            {
                return(BuildShapeBinding(shapeType, template));
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // Should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
            {
                return;
            }

            // Should only run on the Admin
            if (!AdminAttribute.IsApplied(filterContext.HttpContext))
            {
                return;
            }

            // Populate main nav
            IShape menuShape = _shapeFactory.Create("Menu",
                                                    Arguments.From(new
            {
                MenuName  = "admin",
                RouteData = filterContext.RouteData,
            }));

            // Enable shape caching
            menuShape.Metadata.CacheContext
            .Cache("menu-admin")
            .AddContext("roles", "features")
            ;

            _layoutAccessor.GetLayout().Navigation.Add(menuShape);
        }
예제 #5
0
        public async void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var settings = siteSettings.As <LiveChatSettings>();

            // Display only when enabled
            if (settings == null || !settings.Enable)
            {
                return;
            }

            // Don't display on admin pages
            if (AdminAttribute.IsApplied(filterContext.HttpContext))
            {
                return;
            }

            // Should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
            {
                return;
            }

            var content = new HtmlString(settings.Text);

            _resourceManager.RegisterFootScript(content);
        }
예제 #6
0
        public bool TryGetDescriptorBinding(string shapeType, out ShapeBinding shapeBinding)
        {
            if (AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                shapeBinding = null;
                return(false);
            }

            var localTemplates = _previewTemplatesProvider.GetTemplates();

            if (localTemplates != null)
            {
                if (localTemplates.Templates.TryGetValue(shapeType, out var localTemplate))
                {
                    shapeBinding = BuildShapeBinding(shapeType, localTemplate);
                    return(true);
                }
            }

            if (_templatesDocument.Templates.TryGetValue(shapeType, out var template))
            {
                shapeBinding = BuildShapeBinding(shapeType, template);

                return(true);
            }
            else
            {
                shapeBinding = null;
                return(false);
            }
        }
예제 #7
0
        public async Task OnResultExecutionAsync(ResultExecutingContext filterContext, ResultExecutionDelegate next)
        {
            // Dont run in the admin
            if (AdminAttribute.IsApplied(filterContext.HttpContext))
            {
                await next();

                return;
            }

            // You can decide when the filter should be executed here. If this is a ViewResult or PageResult the shape
            // injection wouldn't make any sense since there wouldn't be any zones.
            if (!(filterContext.Result is ViewResult || filterContext.Result is PageResult))
            {
                await next();

                return;
            }

            // The layout can be handled easily if this is dynamic.
            dynamic layout = await _layoutAccessor.GetLayoutAsync();



            // The dynamic Layout object will contain a Zones dictionary that you can use to access a zone.
            var contentZone = layout.Zones["Content"];

            // Here you can add an ad-hoc generated shape to the content zone.
            contentZone.Add(await _shapeFactory.New.NotificationsPanel());

            await next();

            return;
        }
예제 #8
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            // Should only run if user is authenticated
            if (!(context.HttpContext.User.Identity.IsAuthenticated))
            {
                await next.Invoke();

                return;
            }

            // Should only run on the front end home Page
            if (!IsHomePage(context.HttpContext))
            {
                await next.Invoke();

                return;
            }

            // Should only run on the front end not Admin
            if (AdminAttribute.IsApplied(context.HttpContext))
            {
                await next.Invoke();

                return;
            }


            //redirect to custom action to render specific view
//            context.Result =
//                new RedirectToRouteResult(
//                    "my-user-home-page");
            //redirect to custom action to render specific view
            context.Result = new RedirectToActionResult("Index", "AuthenticatedUser", new { area = "Intelli" });
            //  context.Result = new RedirectToRouteResult("my-user-home-page");
        }
        public async Task <LookAndFeelSelectorResult> GetLookAndFeelAsync()
        {
            // Should only run on the front end not Admin
            if (AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                return(null);
            }


            // Should only run if user is authenticated
            var user = _httpContextAccessor.HttpContext.User;

            if (!user.Identity.IsAuthenticated)
            {
                return(null);
            }

            var settings = (await _siteService.GetSiteSettingsAsync()).As <LookAndFeelAuthenticatedUserSettings>();

            if (settings != null)
            {
                string theme  = settings.Theme;
                string layout = settings.Layout;
                if (!string.IsNullOrEmpty(theme))
                {
                    return(new LookAndFeelSelectorResult {
                        Priority = 20, Theme = theme, Layout = layout
                    });
                }
            }

            return(null);
        }
        private Task BuildViewModel(WizardConfigPartViewModel model, WizardConfigPart configPart)
        {
            model.Theme       = configPart.Theme;
            model.IsAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);


            return(Task.CompletedTask);
        }
        public void AuthorizeAuthenticatedAttribute_AsAnonymous()
        {
            var context = generateContext();

            var admin = new AdminAttribute();

            Assert.Throws <AuthorizationException>(() => admin.OnActionExecuting(context));
        }
예제 #12
0
        private Task BuildViewModel(TabPanelPartViewModel model, TabPanelPart part)
        {
            model.Title       = part.Title;
            model.Icon        = part.Icon;
            model.IsAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);


            return(Task.CompletedTask);
        }
        public void AuthorizeAdminAttribute_AsAdmin()
        {
            var context = generateContext();

            context.HttpContext.Request.Headers["Authorization"] = "admin";

            var admin = new AdminAttribute();

            admin.OnActionExecuting(context);
        }
        public void AuthorizeAdminAttribute_AsAuthenticated()
        {
            var context = generateContext();

            context.HttpContext.Request.Headers["Authorization"] = "auth";

            var admin = new AdminAttribute();

            Assert.Throws <AuthorizationException>(() => admin.OnActionExecuting(context));
        }
        private Task BuildViewModel(PartPanelPartViewModel model, PartPanelPart part)
        {
            model.ContentItem   = part.ContentItem;
            model.Part          = part.Part;
            model.Hidden        = part.Hidden;
            model.PartPanelPart = part;

            model.IsAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);
            return(Task.CompletedTask);
        }
        public async Task <LookAndFeelSelectorResult> GetLookAndFeelAsync()
        {
            // Should only run on the front end not Admin
            if (AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                return(null);
            }

            var currentContentItem = await _currentContentItemAccessor.GetCurrentContentItem();

            /*
             * var currentContentItemId = _currentContentItemAccessor.CurrentContentItemId();
             * if (currentContentItemId == null)
             * {
             *   return null;
             *
             * }
             *
             *
             * //this is cached so any other calls in request _contentManager.GetAsync will use the same cached item https://github.com/OrchardCMS/OrchardCore/issues/5052
             * var currentContentItem = await _contentManager.GetAsync(currentContentItemId);
             */
            if (currentContentItem == null)
            {
                return(null);
            }


            var settings = (await _siteService.GetSiteSettingsAsync()).As <LookAndFeelContentTypeSettings>();


            var contentTypeSettings =
                ContentTypeLookAndFeelSettings(settings.SetUpProperties); // site.LookAndFeelSettings();

            contentTypeSettings.TryGetValue(currentContentItem.ContentType, out var themeSettings);
            if (!string.IsNullOrEmpty(themeSettings)) //this is a comma separated string Theme,Layout
            {
                var    themeProperties = themeSettings.Split(',');
                string theme           = themeProperties[0];
                string layout          = themeProperties.Length > 1 ? themeProperties[1] : string.Empty;
                if (!string.IsNullOrEmpty(theme))
                {
                    return(new LookAndFeelSelectorResult {
                        Priority = 10, Theme = theme, Layout = layout
                    });
                }
            }


            //  }

            return(null);
        }
예제 #17
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var controller = context.Controller as Controller;

            if (controller != null)
            {
                if (controller.GetType().Name.StartsWith("Admin"))
                {
                    AdminAttribute.Apply(context.HttpContext);
                }
            }
        }
예제 #18
0
        public override IDisplayResult Edit(ActionsPanelPart part, BuildPartEditorContext context)
        {
            //return Initialize<LayoutPartViewModel>("LayoutPart_Edit", m => BuildViewModel(m, part));
            //add to bus to be picked up by content ishapetableprovider for shifting
            // _httpContextAccessor.HttpContext.Items["PartPanelContainer_CustomerPart"] ="PartPanelContainer_CustomerPart";
            // _httpContextAccessor.HttpContext.Items["PartPanelContainer_SupplierPart"] ="PartPanelContainer_SupplierPart";
            return(Initialize <FlowPartEditViewModel>("ActionsPanelPart_Edit", m =>
            {
                var settings = context.TypePartDefinition.GetSettings <ActionsPanelPartSettings>();   // GetPartSettings(part);
                bool isAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);
                if (isAdminMode == true)
                {
                    if (settings.AllowOverrideActionsPanelPerInstance == true)
                    {
                        //if in admin mode show settings
                        m.FlowPartDisplayMode = settings.FlowPartDisplayMode;
                        m.FlowPartEditMode = settings.FlowPartEditMode;
                        m.FlowPartCreateMode = settings.FlowPartCreateMode;
                    }
                }



                /*
                 * _httpContextAccessor.HttpContext.Items["ActionsPanelPartCorrelationId"] = part.ContentItem.ContentItemId;
                 *
                 *
                 * Dictionary<string, string> flattenedProps =  new Dictionary<string, string>();//
                 * if (context.IsNew)
                 * {
                 *  flattenedProps= Intelli.Core.Helpers.Helpers.GetNotificationPropertiesFromMessageContent(JObject.FromObject(settings.FlowPartCreateMode));
                 * }
                 * else
                 * {
                 *  flattenedProps= Intelli.Core.Helpers.Helpers.GetNotificationPropertiesFromMessageContent(JObject.FromObject(settings.FlowPartEditMode));
                 * }
                 *
                 * var shifted = flattenedProps.Where(x => x.Key.EndsWith("PartPanelPart.Part"));
                 * foreach (var shiftedPanel in shifted)
                 * {
                 *  _httpContextAccessor.HttpContext.Items[$"PartPanelContainer_{shiftedPanel.Value}"] =$"PartPanelContainer_{shiftedPanel.Value}";
                 * }
                 *
                 */
                //based on iscreate or iseditmode pass in appropriate flowpart
                m.FlowPart = context.IsNew == true ? settings.FlowPartCreateMode : settings.FlowPartEditMode;
                m.IsNew = context.IsNew;
                m.Updater = context.Updater;
                //  m.BuildPartDisplayContext = context;
            })
                   .Location("Detail", "Content:5"));
        }
예제 #19
0
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            // Should only run on the front-end (or optionally also on the admin) for a full view.
            if ((context.Result is ViewResult || context.Result is PageResult) &&
                (_options.AllowOnAdmin || !AdminAttribute.IsApplied(context.HttpContext)))
            {
                dynamic layout = await _layoutAccessor.GetLayoutAsync();

                var footerZone = layout.Zones["Footer"];
                footerZone.Add(await _shapeFactory.CreateAsync("MiniProfiler"));
            }

            await next.Invoke();
        }
 public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
 {
     // Should only run on the front-end for a full view
     if ((context.Result is ViewResult || context.Result is PageResult) &&
         !AdminAttribute.IsApplied(context.HttpContext))
     {
         var settings = (await _siteService.GetSiteSettingsAsync()).As <GoogleAnalyticsSettings>();
         if (!string.IsNullOrWhiteSpace(settings?.TrackingID))
         {
             _resourceManager.RegisterHeadScript(new HtmlString($"<script async src=\"https://www.googletagmanager.com/gtag/js?id={settings.TrackingID}\"></script>"));
             _resourceManager.RegisterHeadScript(new HtmlString($"<script>window.dataLayer = window.dataLayer || [];function gtag() {{ dataLayer.push(arguments); }}gtag('js', new Date());gtag('config', '{settings.TrackingID}')</script>"));
         }
     }
     await next.Invoke();
 }
예제 #21
0
        public void Discover(ShapeTableBuilder builder)
        {
            builder.Describe("FlowPart_Edit")
            .OnDisplaying(displaying =>
            {
//                    IF FLOWPART_EDIT  IS SHAPE
//
//                    IF CONTENTTYPE = tABSContainer and  isnot in admin
//                        thena add alternate  TabsContainer-FlowPart-FrontEnd.Edit.cshtml
                var isAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);
                if (isAdminMode == false)
                {
                    if (displaying.Shape is IShape flowPartShape)
                    {
                        var flowPartEditViewModel = displaying.Shape as FlowPartEditViewModel;
                        if (flowPartEditViewModel?.FlowPart.ContentItem != null)
                        {
                            var contentType = flowPartEditViewModel.FlowPart.ContentItem.ContentType;
                            if (contentType == "TabsContainer")
                            {
                                // e.g.TabsContainer-FlowPart-FrontEnd.Edit.cshtml
                                displaying.Shape.Metadata.Alternates.Add($"{contentType}__FlowPart__FrontEnd_Edit");
                            }

                            if (contentType == "TabPanel")
                            {
                                // e.g.TabPanel-FlowPart-FrontEnd.Edit.cshtml
                                displaying.Shape.Metadata.Alternates.Add($"{contentType}__FlowPart__FrontEnd_Edit");
                            }


                            //wizard widget
                            if (contentType == "Wizard")
                            {
                                // e.g.TabsContainer-FlowPart-FrontEnd.Edit.cshtml
                                displaying.Shape.Metadata.Alternates.Add($"{contentType}__FlowPart__FrontEnd_Edit");
                            }

                            if (contentType == "WizardStep")
                            {
                                // e.g.TabPanel-FlowPart-FrontEnd.Edit.cshtml
                                displaying.Shape.Metadata.Alternates.Add($"{contentType}__FlowPart__FrontEnd_Edit");
                            }
                        }
                    }
                }
            });
        }
예제 #22
0
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            // should only run on the front-end for a full view
            if (!((context.Result is ViewResult || context.Result is PageResult) && !AdminAttribute.IsApplied(context.HttpContext)))
            {
                await next.Invoke();

                return;
            }

            try
            {
                var pathBase     = context.HttpContext.Request.PathBase;
                var siteSettings = await _siteService.GetSiteSettingsAsync();

                var faviconSettings = siteSettings.As <ContentItem>("FaviconSettings")?.As <FaviconSettings>() ?? null;

                if (faviconSettings != null && faviconSettings.HasAppleTouchIcon)
                {
                    _resourceManager.RegisterLink(new LinkEntry {
                        Href = $"{pathBase}/icon.png", Rel = "apple-touch-icon"
                    });
                }

                if (faviconSettings != null && faviconSettings.HasFavicon)
                {
                    _resourceManager.RegisterLink(new LinkEntry {
                        Href = $"{pathBase}/favicon.ico", Rel = "shortcut icon"
                    });
                }

                if (faviconSettings != null && faviconSettings.HasWebAppManifest)
                {
                    _resourceManager.RegisterLink(new LinkEntry {
                        Href = $"{pathBase}/site.webmanifest", Rel = "manifest"
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error defining meta/link tags for favicon feature");
            }

            await next.Invoke();
        }
예제 #23
0
        public override async Task <IDisplayResult> UpdateAsync(ListPart listPart, IUpdateModel updater,
                                                                UpdatePartEditorContext context)
        {
            var isAdminMode = AdminAttribute.IsApplied(_httpContextAccessor.HttpContext);

            if (isAdminMode)
            {
                var settings = context.TypePartDefinition.GetSettings <ListPartSettings>();
                if (settings.AllowOverrideDataFillModePerInstance)
                {
                    await updater.TryUpdateModelAsync(listPart, Prefix, m => m.ContainedContentTypes,
                                                      m => m.DataFillMode, m => m.SelectedWorkMapContentItemIds);
                }
            }


            return(Edit(listPart, context));
        }
예제 #24
0
        public async Task OnResultExecutionAsync(ResultExecutingContext filterContext, ResultExecutionDelegate next)
        {
            // Dont run in the admin
            if (AdminAttribute.IsApplied(filterContext.HttpContext))
            {
                await next();

                return;
            }

            // You can decide when the filter should be executed here. If this is a ViewResult or PageResult the shape
            // injection wouldn't make any sense since there wouldn't be any zones.
            if (!(filterContext.Result is ViewResult || filterContext.Result is PageResult))
            {
                await next();

                return;
            }


            //todo
            //this is a temp solution to inject styles because when registering them from shape MessageRoomsListByUser.cshtml is does not work
            //@* https://github.com/OrchardCMS/OrchardCore/issues/3947 *@

            _resourceManager.RegisterResource("stylesheet", "vendor-emoji-picker").AtHead();
            _resourceManager.RegisterResource("stylesheet", "vendor-comments").AtHead();
            _resourceManager.RegisterResource("stylesheet", "vendor-comments-chat").AtHead();
            _resourceManager.RegisterResource("stylesheet", "vendor-bootstrap-linkpreview").AtHead();
            _resourceManager.RegisterResource("stylesheet", "vendor-chatbox-popup").AtHead();

            // The layout can be handled easily if this is dynamic.
            dynamic layout = await _layoutAccessor.GetLayoutAsync();

            //  var asideRightZone = layout.Zones["AsideRightNav"];
            // asideRightZone.Add(await _shapeFactory.New.MessageRoomsSideBarPanel());
            //add sidebar zone  before closing the body tag
            layout.Zones["BodyTagClosingZone"].Add(await _shapeFactory.New.MessageRoomsSideBarPanel());


            //add button to main content area to trigger sidebar toggle
            layout.Zones["MainLayoutActionsZone"].Add(await _shapeFactory.New.MessageRoomsSideBarTriggerAction());

            await next();
        }
예제 #25
0
 public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
 {
     // Should only run on the front-end for a full view
     if ((context.Result is ViewResult || context.Result is PageResult) &&
         !AdminAttribute.IsApplied(context.HttpContext))
     {
         var site     = (await _siteService.GetSiteSettingsAsync());
         var settings = site.As <FacebookSettings>();
         if (!string.IsNullOrWhiteSpace(settings?.AppId))
         {
             if (settings.FBInit)
             {
                 var setting = _resourceManager.RegisterResource("script", "fb");
                 setting.AtLocation(ResourceLocation.Foot);
             }
         }
     }
     await next.Invoke();
 }
        public async Task <ThemeSelectorResult> GetThemeAsync()
        {
            if (AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                string adminThemeName = await _adminThemeService.GetAdminThemeNameAsync();

                if (String.IsNullOrEmpty(adminThemeName))
                {
                    return(null);
                }

                return(new ThemeSelectorResult
                {
                    Priority = 100,
                    ThemeName = adminThemeName
                });
            }

            return(null);
        }
예제 #27
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            // Should only run on the Admin
            if (!AdminAttribute.IsApplied(context.HttpContext))
            {
                await next.Invoke();

                return;
            }

            // Should only run on the Admin Home Page
            if (!(context.HttpContext.GetRouteValue("area").ToString() == "OrchardCore.Media" && context.HttpContext.GetRouteValue("controller").ToString() == "Admin" && context.HttpContext.GetRouteValue("action").ToString() == "Index"))
            {
                await next.Invoke();

                return;
            }
            //redirect to inspiniaadmin custom actions
            context.Result = new RedirectToActionResult("Index", "MediaAdmin", new { area = "InspiniaAdmin2" });

            //  await next();
            // var httpMethod = context.HttpContext.Request.Method;
            //var routeValues = context.RouteData.Values;


//            var workflowTypeEntries = _workflowTypeRouteEntries.GetWorkflowRouteEntries(httpMethod, routeValues);
//            var workflowEntries = _workflowRouteEntries.GetWorkflowRouteEntries(httpMethod, routeValues);
//
//            if (workflowTypeEntries.Any())
//            {
//                var workflowTypeIds = workflowTypeEntries.Select(x => Int32.Parse(x.WorkflowId)).ToList();
//                var workflowTypes = (await _workflowTypeStore.GetAsync(workflowTypeIds)).ToDictionary(x => x.Id);
//
//                foreach (var entry in workflowTypeEntries)
//                {
//                    var workflowType = workflowTypes[Int32.Parse(entry.WorkflowId)];
//                    var activity = workflowType.Activities.Single(x => x.ActivityId == entry.ActivityId);
//                    await _workflowManager.StartWorkflowAsync(workflowType, activity);
//                }
//            }
        }
예제 #28
0
        public async Task OnResultExecutionAsync(
            ResultExecutingContext context,
            ResultExecutionDelegate next)
        {
            //Only inject in client
            if (!AdminAttribute.IsApplied(context.HttpContext) && (context.Result is ViewResult ||
                                                                   context.Result is PageResult))
            {
                var settings = (await _siteService.GetSiteSettingsAsync()).As <BuyMeCoffeeSettings>();

                if (!string.IsNullOrEmpty(settings.DataId))
                {
                    // build the script
                    var script = ScriptBuilder(settings);

                    _resourceManager.RegisterHeadScript(new HtmlString(script));
                }
            }

            await next.Invoke();
        }
예제 #29
0
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            if ((context.Result is ViewResult || context.Result is PageResult) && !AdminAttribute.IsApplied(context.HttpContext))
            {
                if (_scriptsCache == null)
                {
                    var settings = (await _siteService.GetSiteSettingsAsync()).As <CivicCookieControlSettings>();

                    if (settings?.IsValid ?? false)
                    {
                        _scriptsCache = new HtmlString($"<script src=\"https://cc.cdn.civiccomputing.com/9/cookieControl-9.x.min.js\"></script><script>var config = {_cookieControlSettingsService.ToJson(settings)}; CookieControl.load( config );</script>");
                    }
                }

                if (_scriptsCache != null)
                {
                    _resourceManager.RegisterHeadScript(_scriptsCache);
                }
            }

            await next.Invoke();
        }
예제 #30
0
        public async Task <ThemeSelectorResult> GetThemeAsync()
        {
            // Should only run on the front-end for a full view
            if (!AdminAttribute.IsApplied(_httpContextAccessor.HttpContext))
            {
                var customLookAndFeel = await  GetLookAndFeelAsync();

                if (customLookAndFeel != null && !String.IsNullOrWhiteSpace(customLookAndFeel.Theme))
                {
                    //var currentThemeName = await _siteThemeService.GetCurrentThemeNameAsync();
                    //if (string.IsNullOrEmpty(currentThemeName))
                    //   return null;
                    //set to higher priority tham SiteThemeSelector to win
                    //  return new ThemeSelectorResult { Priority = 1, ThemeName = context.HttpContext.Items["IntelliTheme"].ToString() };

                    // Priority should override current theme priority, but not admin theme priority.
                    // Admin Theme Priority = 100
                    // Current Theme Priority = 0

                    //check and set custom layout
                    if (!string.IsNullOrEmpty(customLookAndFeel.Layout))
                    {
                        _httpContextAccessor.HttpContext.Items["IntelliLayout"] = customLookAndFeel.Layout;
//                       var layoutAccessor = _serviceProvider.GetService<ILayoutAccessor>();
//                       IShape layoutShape = await layoutAccessor.GetLayoutAsync();
//                       layoutShape?.Metadata.Alternates.Add("Layout__" + customLookAndFeel.Layout);
                    }

                    return(new ThemeSelectorResult
                    {
                        Priority = Priority,
                        ThemeName = customLookAndFeel.Theme
                    });
                }
            }

            return(null);
        }