Esempio n. 1
0
 public static string GetCongressResources(Enums.UseLayout layout = Enums.UseLayout.None)
 {
     if (SessionParameters.CurrentCongress == null)
     {
         return(string.Empty);
     }
     return(CongressComponent.Instance.BaseInfoComponents.ResourceFacade.GetCongressResourceHtml(
                SessionParameters.CurrentCongress.Id, SessionParameters.Culture, layout));
 }
Esempio n. 2
0
 public string GetCongressResourceHtml(Guid congress, string culture, Enums.UseLayout layout)
 {
     try
     {
         return(new ResourceBO().GetCongressResourceHtml(ConnectionHandler, congress, culture, layout));
     }
     catch (KnownException knownException)
     {
         throw new KnownException(knownException.Message, knownException);
     }
     catch (Exception ex)
     {
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 3
0
        public string GetCongressResourceHtml(IConnectionHandler connectionHandler, Guid congressId, string culture, Enums.UseLayout layout)
        {
            try
            {
                var str = new StringWriter();
                var html32TextWriter = new Html32TextWriter(str);
                var byFilter         = new ResourceBO().OrderBy(connectionHandler, x => x.Order, x => x.CongressId == congressId && x.Enabled);
                if (!string.IsNullOrEmpty(culture))
                {
                    new ResourceBO().GetLanuageContent(connectionHandler, culture, byFilter);
                }

                foreach (var resource in byFilter)
                {
                    if (layout != Enums.UseLayout.None &&
                        (string.IsNullOrEmpty(resource.UseLayoutId) ||
                         (!resource.UseLayoutId.Split(',').Contains(((byte)layout).ToString()))))
                    {
                        continue;
                    }

                    switch ((Enums.ResourceType)resource.Type)
                    {
                    case Enums.ResourceType.JSFile:
                        if (resource.FileId == null)
                        {
                            continue;
                        }
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Src, FileManagerContants.FileHandlerRoot + resource.FileId);
                        html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Script);
                        html32TextWriter.RenderEndTag();
                        break;

                    case Enums.ResourceType.CssFile:
                        if (resource.FileId == null)
                        {
                            continue;
                        }
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Href, FileManagerContants.FileHandlerRoot + resource.FileId);
                        html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Link);
                        html32TextWriter.RenderEndTag();
                        break;

                    case Enums.ResourceType.JSFunction:
                        if (string.IsNullOrEmpty(resource.Text))
                        {
                            continue;
                        }
                        html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
                        html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style);
                        html32TextWriter.Write(resource.Text);
                        html32TextWriter.RenderEndTag();
                        break;

                    case Enums.ResourceType.Style:
                        if (string.IsNullOrEmpty(resource.Text))
                        {
                            continue;
                        }
                        html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style);
                        html32TextWriter.Write(resource.Text);
                        html32TextWriter.RenderEndTag();
                        break;
                    }
                }
                return(str.ToString());
            }
            catch (KnownException knownException)
            {
                throw new KnownException(knownException.Message, knownException);
            }
            catch (Exception ex)
            {
                throw new KnownException(ex.Message, ex);
            }
        }