LocalDB.tt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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,1433","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,"LocalApp.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 LocalDB
  58. {
  59. namespace DBSchema
  60. {
  61. <#=db.GetProduceDefine() #>
  62. }
  63. namespace DBNames
  64. {
  65. <#=db.GetTableColumnsDefine() #>
  66. <#=db.GetViewColumnsDefine() #>
  67. <#=db.GetProduceParametersDefine() #>
  68. }
  69. namespace DBModel
  70. {
  71. <#= db.GetDBModel() #>
  72. }
  73. namespace DIL
  74. {
  75. <#if(db is SQLDB)
  76. {
  77. WriteLine(" public class DILDB:SQLDB");
  78. }
  79. else if(db is MySQLDB)
  80. {
  81. WriteLine(" public class DILDB:MySQLDB");
  82. }
  83. else if(db is SQLiteDB)
  84. {
  85. WriteLine(" public class DILDB:SQLiteDB");
  86. }
  87. else if(db is OracleDB)
  88. {
  89. WriteLine(" public class DILDB:OracleDB");
  90. }
  91. else if(db is NpgSQLDB)
  92. {
  93. WriteLine(" public class DILDB:NpgSQLDB");
  94. }
  95. #>
  96. {
  97. <#= db.GetDeclare() #>
  98. }
  99. }
  100. }