Esempio n. 1
0
        public TemplateContent GetTemplate(TemplateProperty templateProperty)
        {
            string file = string.Format("/{0}/{1}/{2}/{3}/{4}",
                                        templateProperty.ClientId, templateProperty.Language, templateProperty.Year,
                                        templateProperty.BizGroup, templateProperty.TemplateName);

            FileInfo fi = fileProvider.GetFile(file);

            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}/{3}",
                                     templateProperty.Language, templateProperty.Year,
                                     templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}",
                                     templateProperty.Language,
                                     templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}",
                                     templateProperty.Year,
                                     templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}",
                                     templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}", templateProperty.TemplateName);
                fi   = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                throw new FileNotFoundException(DAF.Core.Resources.Locale(o => o.FileNotFound), file);
            }

            string body = File.ReadAllText(fi.FullName);

            TemplateContent content = new TemplateContent()
            {
                FilePath = file,
                Name     = templateProperty.TemplateName,
                Body     = body
            };

            return(content);
        }
Esempio n. 2
0
        public TemplateContent GetTemplate(TemplateProperty templateProperty)
        {
            string file = string.Format("/{0}/{1}/{2}/{3}/{4}",
                templateProperty.ClientId, templateProperty.Language, templateProperty.Year,
                templateProperty.BizGroup, templateProperty.TemplateName);

            FileInfo fi  = fileProvider.GetFile(file);
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}/{3}",
                templateProperty.Language, templateProperty.Year,
                templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}",
                templateProperty.Language,
                templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}/{2}",
                templateProperty.Year,
                templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}/{1}",
                templateProperty.BizGroup, templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
            {
                file = string.Format("/{0}", templateProperty.TemplateName);
                fi = fileProvider.GetFile(file);
            }
            if (!fi.Exists)
                throw new FileNotFoundException(DAF.Core.Resources.Locale(o => o.FileNotFound), file);

            string body = File.ReadAllText(fi.FullName);

            TemplateContent content = new TemplateContent()
            {
                FilePath = file,
                Name = templateProperty.TemplateName,
                Body = body
            };
            return content;
        }
Esempio n. 3
0
        public TemplateResult LoadTemplate(object data, TemplateProperty templateProperty)
        {
            TemplateContent content = fileProvider.GetTemplate(templateProperty);
            if (content == null)
                return null;

            TemplateResult result = null;
            foreach (var g in generators)
            {
                result = g.GenerateResult(data, content);
                if (result != null)
                    break;
            }

            return result;
        }
Esempio n. 4
0
        public TemplateResult LoadTemplate(object data, TemplateProperty templateProperty)
        {
            TemplateContent content = fileProvider.GetTemplate(templateProperty);

            if (content == null)
            {
                return(null);
            }

            TemplateResult result = null;

            foreach (var g in generators)
            {
                result = g.GenerateResult(data, content);
                if (result != null)
                {
                    break;
                }
            }

            return(result);
        }