项目作者: dalenewman

项目描述 :
Velocity Provider for Transformalize
高级语言: C#
项目地址: git://github.com/dalenewman/Transformalize.Provider.Velocity.git
创建时间: 2019-03-29T04:58:49Z
项目社区:https://github.com/dalenewman/Transformalize.Provider.Velocity

开源协议:Apache License 2.0

下载


Overview

This adds a velocity provider and transform to Transformalize using NVelocity.

Build the Autofac project and put it’s output into Transformalize’s plugins folder.

Write Usage

  1. <add name='TestProcess' mode='init'>
  2. <connections>
  3. <add name='input' provider='bogus' seed='1' ></add>
  4. <add name='output' provider='Velocity' template='template.vtl' file='output.html' ></add>
  5. </connections>
  6. <entities>
  7. <add name='Contact' size='1000'>
  8. <fields>
  9. <add name='Identity' type='int' primary-key='true' ></add>
  10. <add name='FirstName' ></add>
  11. <add name='LastName' ></add>
  12. <add name='Stars' type='byte' min='1' max='5' ></add>
  13. <add name='Reviewers' type='int' min='0' max='500' ></add>
  14. </fields>
  15. </add>
  16. </entities>
  17. </add>

This writes 1000 rows of bogus data to output.html.

The template template.vtl is passed a VelocityModel. The template in this example looks like this:

  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Velocity Output</title>
  6. </head>
  7. <body>
  8. <table>
  9. <thead>
  10. <tr>
  11. #foreach($field in $Model.Entity.Fields)
  12. #if(!$field.System)<th>$field.Label</th> #end
  13. #end
  14. </tr>
  15. </thead>
  16. <tbody>
  17. #foreach($row in $Model.Rows)
  18. <tr>
  19. #foreach($field in $Model.Entity.Fields)
  20. #if(!$field.System)<td>$row.get_Item($field)</td> #end
  21. #end
  22. </tr>
  23. #set( $Model.Entity.Inserts = $Model.Entity.Inserts + 1 )
  24. #end
  25. </tbody>
  26. </table>
  27. </body>
  28. </html>

The table in output.html looks like this (clipped for brevity):
















































Identity FirstName LastName Stars Reviewers
1 Justin Konopelski 3 153
2 Eula Schinner 2 41
3 Tanya Shanahan 4 412
4 Emilio Hand 4 469
5 Rachel Abshire 3 341

Benchmark

Note: Numbers get better with more records.

  1. BenchmarkDotNet=v0.11.4, OS=Windows 10.0.17134.407 (1803/April2018Update/Redstone4)
  2. Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
  3. Frequency=2742192 Hz, Resolution=364.6718 ns, Timer=TSC
  4. [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3221.0
  5. LegacyJitX64 : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit LegacyJIT/clrjit-v4.7.3221.0;compatjit-v4.7.3221.0
  6. Job=LegacyJitX64 Jit=LegacyJit Platform=X64
  7. Runtime=Clr
Method Mean Error StdDev Median Ratio RatioSD
‘10000 test rows’ 987.5 ms 22.37 ms 44.68 ms 968.8 ms 1.00 0.00
‘10000 rows with 1 Velocity’ 1,726.7 ms 27.51 ms 25.74 ms 1,722.5 ms 1.75 0.07