Exemplo n.º 1
0
        public ProxyRenderContext(ControllerContext controllerContext,
                                  PageRequestContext pageRequestContext, ProxyPosition proxyPosition, string requestPath)
        {
            this.ControllerContext  = controllerContext;
            this.PageRequestContext = pageRequestContext;
            this.ProxyPosition      = proxyPosition;


            if (string.IsNullOrEmpty(requestPath) && PageRequestContext != null)
            {
                requestPath = pageRequestContext.ModuleUrlContext.GetModuleUrl(proxyPosition.PagePositionId);
            }

            if (string.IsNullOrEmpty(requestPath))
            {
                requestPath = proxyPosition.RequestPath;
            }
            requestPath = requestPath.Trim('~').Trim();

            RequestUri = new Uri(proxyPosition.HostUri, requestPath);

            var httpMethod = controllerContext.HttpContext.Request.HttpMethod;

            if (httpMethod.ToUpper() == "POST" && pageRequestContext != null)
            {
                var postModule = pageRequestContext.AllQueryString[Kooboo.CMS.Sites.View.ModuleUrlContext.PostModuleParameter];
                if (postModule != proxyPosition.PagePositionId)
                {
                    httpMethod = "GET";
                }
            }
            HttpMethod = httpMethod;
        }
Exemplo n.º 2
0
 public virtual ActionResult ProcessProxy(ProxyPosition pos)
 {
     if (IsGet())
     {
         ViewData["Policys"] = Enum.GetNames(typeof(ExpirationPolicy));
         ViewData.ModelState.Clear();
         return(View(pos));
     }
     else
     {
         return(Json(new { html = new PageDesignProxyContent(pos).ToHtmlString() }));
     }
 }
Exemplo n.º 3
0
 public PageDesignProxyContent(ProxyPosition pos)
     : base(pos)
 {
     this.Parameter["Host"]        = pos.Host;
     this.Parameter["RequestPath"] = pos.RequestPath;
     this.Parameter["NoProxy"]     = pos.NoProxy.ToString().ToLower();
     if (pos.OutputCache != null)
     {
         var outputCacheJson = new
         {
             Duration         = pos.OutputCache.Duration,
             ExpirationPolicy = pos.OutputCache.ExpirationPolicy.ToString()
         };
         var serializer            = new JavaScriptSerializer();
         var outputCacheJsonString = serializer.Serialize(outputCacheJson);
         this.Parameter.Add("OutputCache", PageDesignContent.Code(outputCacheJsonString));
     }
 }
Exemplo n.º 4
0
 protected virtual IHtmlString RenderProxyPosition(ProxyPosition proxyPosition)
 {
     return(ProxyRender.Render(PageContext, proxyPosition.PagePositionId, proxyPosition.Host, proxyPosition.RequestPath, proxyPosition.NoProxy, proxyPosition.OutputCache));
 }
Exemplo n.º 5
0
 protected virtual IHtmlString RenderProxyPosition(ProxyPosition proxyPosition)
 {
     return(ProxyRender.Render(new ProxyRenderContext(PageContext.ControllerContext, PageContext.PageRequestContext, proxyPosition, null)));
 }
Exemplo n.º 6
0
        // public method
        public static List <PagePosition> ParsePagePositions(string clientJson)
        {
            clientJson = HttpUtility.UrlDecode(clientJson);

            var positions = new List <PagePosition>();
            var list      = ParseJson <List <Dictionary <string, object> > >(clientJson);

            foreach (var item in list)
            {
                PagePosition pos = null;
                var          t   = item.Str("Type");
                if (t == PageDesignViewContent.TypeKey)
                {
                    pos = new ViewPosition()
                    {
                        ViewName    = item.Str("ViewName"),
                        Parameters  = ParseViewParameters(item.Str("Parameters")),
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                else if (t == PageDesignModuleContent.TypeKey)
                {
                    pos = new ModulePosition()
                    {
                        ModuleName = item.Str("ModuleName"),
                        Exclusive  = (item.Str("Exclusive") == "true"),
                        Entry      = ParseModuleEntry(item)
                    };
                }
                else if (t == PageDesignFolderContent.TypeKey)
                {
                    pos = new ContentPosition()
                    {
                        Type     = ParseEnum <ContentPositionType>(item.Str("ContentPositionType")),
                        DataRule = ParseJson <FolderDataRule>(item.Str("DataRule"))
                    };
                }
                else if (t == PageDesignHtmlContent.TypeKey)
                {
                    pos = new HtmlPosition()
                    {
                        Html = item.Str("Html")
                    };
                }
                else if (t == PageDesignHtmlBlockContent.TypeKey)
                {
                    pos = new HtmlBlockPosition()
                    {
                        BlockName = item.Str("BlockName")
                    };
                }
                else if (t == PageDesignProxyContent.TypeKey)
                {
                    pos = new ProxyPosition()
                    {
                        Host        = item.Str("Host"),
                        RequestPath = item.Str("RequestPath"),
                        NoProxy     = item.Str("NoProxy") == "true",
                        OutputCache = ParseJson <CacheSettings>(item.Str("OutputCache"))
                    };
                }
                // add
                if (pos != null)
                {
                    pos.LayoutPositionId = item.Str("LayoutPositionId");
                    pos.PagePositionId   = item.Str("PagePositionId");
                    pos.Order            = item.Int("Order");
                    positions.Add(pos);
                }
            }
            // ret
            return(positions);
        }