Beispiel #1
0
 internal override void Run(TemplateEnviroment env)
 {
     foreach (CompiledTemplate item in m_items)
     {
         item.Run(env);
     }
 }
Beispiel #2
0
        internal override void Run(TemplateEnviroment env)
        {
            object obj = m_func();

            env.Writer.Write(obj);
            env.Writer.Flush();
        }
Beispiel #3
0
        internal override void Run(TemplateEnviroment env)
        {
            LanguageQueryFunc func      = (LanguageQueryFunc)m_engine.DefaultModule.Globals["query"];
            IDatabaseSource   dbcontext = (IDatabaseSource)m_engine.DefaultModule.Globals["dbcontext"];
            string            sql       = MakeSqlSubs(m_select, m_engine);
            IBedReader        reader    = dbcontext.GetAnyDDA().AdaptReader(func(sql));

            reader.RunForEachRecordAndDispose(dbcontext.Dialect.DialectCaps.MARS, (rec, index) => ProcessRecord(rec, env, index));
        }
Beispiel #4
0
        internal override void Run(TemplateEnviroment env)
        {
            string            sql  = SelectTemplate.MakeSqlSubs(m_query, m_engine);
            LanguageQueryFunc func = (LanguageQueryFunc)m_engine.DefaultModule.Globals["query"];

            using (IDataReader reader = func(sql))
            {
                if (reader.Read())
                {
                    env.Writer.Write(reader[0].SafeToString());
                }
            }
        }
Beispiel #5
0
 private void ProcessRecord(IBedRecord record, TemplateEnviroment env, int index)
 {
     if (index > 0 && m_separ != null)
     {
         m_separ.Run(env);
     }
     m_engine.Globals["_row_"] = record;
     for (int fi = 0; fi < record.FieldCount; fi++)
     {
         m_engine.Globals["_" + record.GetName(fi).ToLower() + "_"] = record.GetValue(fi).SafeToString();
     }
     m_body.Run(env);
 }
Beispiel #6
0
        public static RunTextWriterDelegate CompileScript(string code, TextGeneratorLanguage language)
        {
            switch (language)
            {
            case TextGeneratorLanguage.Python:
                return(delegate(Stream fw, IDictionary <string, object> extnames, IDictionary <string, object> outnames)
                {
                    PythonEngine engine = new PythonEngine();
                    ScriptingEnv.InitializeEngine(engine);
                    engine.SetStandardOutput(fw);
                    CompiledCode compiled = engine.Compile(code);
                    //if (node != null) node.GetScriptingNS(engine.DefaultModule.Globals);
                    if (extnames != null)
                    {
                        foreach (string key in extnames.Keys)
                        {
                            engine.DefaultModule.Globals[key] = extnames[key];
                        }
                    }
                    compiled.Execute();
                    if (outnames != null)
                    {
                        foreach (string key in engine.DefaultModule.Globals.Keys)
                        {
                            outnames[key] = engine.DefaultModule.Globals[key];
                        }
                    }
                });

            case TextGeneratorLanguage.Template:
                return(delegate(Stream fw, IDictionary <string, object> extnames, IDictionary <string, object> outnames)
                {
                    PythonEngine engine = new PythonEngine();
                    engine.SetStandardOutput(fw);
                    ScriptingEnv.InitializeEngine(engine);
                    //if (node != null) node.GetScriptingNS(engine.DefaultModule.Globals);
                    if (extnames != null)
                    {
                        foreach (string key in extnames.Keys)
                        {
                            engine.DefaultModule.Globals[key] = extnames[key];
                        }
                    }
                    Template tpl = new Template(code, engine);
                    StreamWriter sw = new StreamWriter(fw);
                    TemplateEnviroment env = new TemplateEnviroment(sw);
                    tpl.Run(env);
                });
            }
            throw new Exception("DAE-00258 internal error");
        }
Beispiel #7
0
        internal override void Run(TemplateEnviroment env)
        {
            bool was = false;

            foreach (object obj in (System.Collections.IEnumerable)m_container())
            {
                if (was && m_separ != null)
                {
                    m_separ.Run(env);
                }
                m_engine.DefaultModule.Globals[m_varname] = obj;
                m_body.Run(env);
                was = true;
            }
        }
Beispiel #8
0
 internal override void Run(TemplateEnviroment env)
 {
     env.Writer.Write(m_data);
     env.Writer.Flush();
 }
Beispiel #9
0
 internal abstract void Run(TemplateEnviroment env);
Beispiel #10
0
 public void Run(TemplateEnviroment env)
 {
     m_template.Run(env);
 }