DBSchema.tt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <#@ template debug="true" hostspecific="true" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ assembly name="System.Data" #>
  4. <#@ assembly name="$(SolutionDir)\Lib\SCADA.CommonLib.dll" #>
  5. <#@ assembly name="$(SolutionDir)\Lib\System.Data.SQLite.dll" #>
  6. <#@ import namespace="System.Linq" #>
  7. <#@ import namespace="System.Text" #>
  8. <#@ import namespace="System.Collections.Generic" #>
  9. <#@ import namespace="System.Data" #>
  10. <#@ import namespace="SCADA.CommonLib.Data"#>
  11. <#@ import namespace="SCADA.CommonLib.Data.DIL"#>
  12. <#@ import namespace="SCADA.CommonLib.Data.DIL.MSSql"#>
  13. <#@ import namespace="SCADA.CommonLib.Data.DIL.MySql"#>
  14. <#@ import namespace="SCADA.CommonLib.Data.DIL.Sqlite"#>
  15. <#@ import namespace="SCADA.CommonLib.Data.DIL.Oracle"#>
  16. <#@ import namespace="SCADA.CommonLib.Data.DIL.NpgSql"#>
  17. <#@ import namespace="SCADA.CommonLib.Data.DIL.Sqlite"#>
  18. <#@ import namespace="Microsoft.VisualStudio.TextTemplating"#>
  19. <#@ output extension=".cs" #>
  20. <#
  21. string ttpath = this.Host.TemplateFile;
  22. string projectPath=Host.ResolveAssemblyReference("$(SolutionDir)");
  23. string outPath=Host.ResolveAssemblyReference("$(TargetDir)");
  24. //IDB db=new SQLDB("127.0.0.1","EICP","sa","123456");
  25. // IDB db=new OracleDB("127.0.0.1:1521","EICP","sa","123456");
  26. // IDB db=new MySQLDB("127.0.0.1:3306","EICP","sa","123456");
  27. string dataPath=@$"{projectPath}\SCADA_DAQ\bin\Debug\net47\Data";
  28. IDB db=new SQLiteDB(dataPath,"QwPlatform.db");
  29. #>
  30. using System;
  31. using System.Collections.Generic;
  32. using SCADA.CommonLib;
  33. using SCADA.CommonLib.Data;
  34. using SCADA.CommonLib.Data.DIL;
  35. <#if(db is SQLDB)
  36. {
  37. WriteLine("using System.Data.SqlClient;");
  38. WriteLine("using SCADA.CommonLib.Data.DIL.MSSql;");
  39. }
  40. else if(db is MySQLDB)
  41. {
  42. WriteLine("using SCADA.CommonLib.Data.DIL.MySql;");
  43. }
  44. else if(db is SQLiteDB)
  45. {
  46. WriteLine("using SCADA.CommonLib.Data.DIL.Sqlite;");
  47. }
  48. else if(db is OracleDB)
  49. {
  50. WriteLine("using SCADA.CommonLib.Data.DIL.Oracle;");
  51. }
  52. else if(db is NpgSQLDB)
  53. {
  54. WriteLine("using SCADA.CommonLib.Data.DIL.NpgSql;");
  55. }
  56. #>
  57. namespace DBSchema
  58. {
  59. <#=db.GetProduceDefine() #>
  60. }
  61. namespace DBNames
  62. {
  63. <#=db.GetTableColumnsDefine() #>
  64. <#=db.GetViewColumnsDefine() #>
  65. <#=db.GetProduceParametersDefine() #>
  66. }
  67. namespace DBModel
  68. {
  69. <#= db.GetDBModel() #>
  70. }
  71. namespace DIL
  72. {
  73. <#if(db is SQLDB)
  74. {
  75. WriteLine(" public class DILDB:SQLDB");
  76. }
  77. else if(db is MySQLDB)
  78. {
  79. WriteLine(" public class DILDB:MySQLDB");
  80. }
  81. else if(db is SQLiteDB)
  82. {
  83. WriteLine(" public class DILDB:SQLiteDB");
  84. }
  85. else if(db is OracleDB)
  86. {
  87. WriteLine(" public class DILDB:OracleDB");
  88. }
  89. else if(db is NpgSQLDB)
  90. {
  91. WriteLine(" public class DILDB:NpgSQLDB");
  92. }
  93. #>
  94. {
  95. <#= db.GetDeclare() #>
  96. }
  97. }