Language.tt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <#@ template debug="true" hostspecific="true" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ assembly name="System.Data" #>
  4. <#@ import namespace="System.Linq" #>
  5. <#@ import namespace="System.Text" #>
  6. <#@ import namespace="System.Data" #>
  7. <#@ import namespace="System.Collections.Generic" #>
  8. <#@ assembly name="$(SolutionDir)\Lib\NPOI.dll" #>
  9. <#@ assembly name="$(SolutionDir)\Lib\ICSharpCode.SharpZipLib.dll" #>
  10. <#@ assembly name="$(SolutionDir)\Lib\SCADA.CommonCtrl.dll" #>
  11. <#@ import namespace="Microsoft.VisualStudio.TextTemplating"#>
  12. <#@include file="Manager.ttinclude"#>
  13. <# var manager = Manager.Create(Host, GenerationEnvironment);
  14. string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");
  15. string projectPath = Host.ResolveAssemblyReference("$(ProjectDir)");
  16. var dt=SCADA.CommonCtrl.ExcelHelper.GetImportDataTable(@$"{projectPath}语言文件.xlsx","语言文件",3); #>
  17. namespace SCADA_DAQ.Language
  18. {
  19. public class LanguageKeys
  20. {
  21. <#
  22. for(int j=0;j<dt.Rows.Count;j++){
  23. var key=dt.Rows[j][0]?.ToString();
  24. if(!string.IsNullOrEmpty(key))
  25. {
  26. var content=dt.Rows[j][1]?.ToString();
  27. if(!string.IsNullOrEmpty(content))
  28. {
  29. #>
  30. ///<summary><#=content#>
  31. ///</summary>
  32. public const string <#=key#> ="<#=key#>";
  33. <# }
  34. else
  35. {
  36. #>
  37. <# }
  38. }
  39. else
  40. {
  41. var ann=dt.Rows[j][1]?.ToString();
  42. if(!string.IsNullOrEmpty(ann))
  43. {
  44. #>
  45. <# }
  46. else
  47. {
  48. #>
  49. <#
  50. }
  51. }
  52. }
  53. #>
  54. }
  55. }
  56. <#
  57. for(int i=1;i<dt.Columns.Count;i++){
  58. string filename = dt.Columns[i].ColumnName.ToString()+".xaml";
  59. manager.StartNewFile(filename);
  60. #>
  61. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  62. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  63. xmlns:s="clr-namespace:System;assembly=mscorlib">
  64. <# for(int j=0;j<dt.Rows.Count;j++){
  65. var key=dt.Rows[j][0]?.ToString();
  66. if(!string.IsNullOrEmpty(key))
  67. {
  68. var content=dt.Rows[j][i]?.ToString();
  69. if(!string.IsNullOrEmpty(content))
  70. {
  71. #>
  72. <s:String x:Key="<#=key#>"><#=dt.Rows[j][i]#></s:String>
  73. <# }
  74. else
  75. {
  76. #>
  77. <# }
  78. }
  79. else
  80. {
  81. var ann=dt.Rows[j][1]?.ToString();
  82. if(!string.IsNullOrEmpty(ann))
  83. {
  84. #>
  85. <!--<#=ann#>-->
  86. <# }
  87. else
  88. {
  89. #>
  90. <#
  91. }
  92. }
  93. }#>
  94. </ResourceDictionary>
  95. <#
  96. manager.EndBlock();
  97. #>
  98. <#
  99. }
  100. #>
  101. <# manager.Process(true); #>