NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Data.Provider.MySqlFactory Class Reference
Inheritance diagram for Ntp.Data.Provider.MySqlFactory:
Collaboration diagram for Ntp.Data.Provider.MySqlFactory:

Public Member Functions

override IDbCommand CreateCommand ()
 
override IDbConnection CreateConnection ()
 
override void CreateDatabase ()
 
override IDbConnection CreateGenericConnection ()
 
override IDbDataParameter CreateParameter (string name, object value)
 
override string DateAddMinutes (string dateColumn, string minuteColumn)
 
override string PrepareCheckTableSql (string table)
 
override string PrepareCreateTableSql (string sql)
 
override string PrepareInsertSql (string sql)
 
override string PrepareSql (string sql)
 

Package Functions

 MySqlFactory ()
 

Static Private Member Functions

static string BuildConnectionString (bool includeName=true)
 

Private Attributes

const string CheckTableSql
 
const string CreateDatabaseSql
 

Additional Inherited Members

- Static Public Member Functions inherited from Ntp.Data.Provider.SqlDatabaseFactory
static void Initialize (IDatabaseConfiguration factoryConfiguration)
 
- Static Protected Attributes inherited from Ntp.Data.Provider.SqlDatabaseFactory
static IDatabaseConfiguration Config
 
- Properties inherited from Ntp.Data.Provider.SqlDatabaseFactory
static SqlDatabaseFactory Instance [get]
 

Detailed Description

Definition at line 29 of file MySqlFactory.cs.

Constructor & Destructor Documentation

Ntp.Data.Provider.MySqlFactory.MySqlFactory ( )
inlinepackage

Definition at line 31 of file MySqlFactory.cs.

32  {
33  }

Member Function Documentation

static string Ntp.Data.Provider.MySqlFactory.BuildConnectionString ( bool  includeName = true)
inlinestaticprivate

Definition at line 101 of file MySqlFactory.cs.

References b.

102  {
103  if (Config.ConnectionString != null)
104  return Config.ConnectionString;
105 
106  var b = new StringBuilder();
107  b.Append($"Server={Config.Host};");
108 
109  if (Config.Port != null)
110  b.Append($"Port={Config.Port};");
111 
112  if (includeName)
113  b.Append($"Database={Config.Name};");
114 
115  b.Append($"Uid={Config.User};");
116  b.Append($"Pwd={Config.Pass};");
117 
118  if (Config.EnableSsl)
119  b.Append(@"SSL Mode=Required;");
120 
121  if (Config.CertificateFile != null)
122  b.Append($"CertificateFile={Config.CertificateFile};");
123 
124  if (Config.CertificatePassword != null)
125  b.Append($"CertificatePassword={Config.CertificatePassword};");
126 
127  if (Config.ConnectionTimeout.HasValue)
128  b.Append($"Connection Timeout={Config.ConnectionTimeout.Value};");
129 
130  return b.ToString();
131  }
static IDatabaseConfiguration Config
var b
Definition: bootstrap.min.js:6
override IDbCommand Ntp.Data.Provider.MySqlFactory.CreateCommand ( )
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 44 of file MySqlFactory.cs.

45  {
46  return new MySqlCommand();
47  }
override IDbConnection Ntp.Data.Provider.MySqlFactory.CreateConnection ( )
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 49 of file MySqlFactory.cs.

50  {
51  return new MySqlConnection(BuildConnectionString());
52  }
static string BuildConnectionString(bool includeName=true)
override void Ntp.Data.Provider.MySqlFactory.CreateDatabase ( )
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 55 of file MySqlFactory.cs.

56  {
57  var connection = CreateGenericConnection();
58  connection.Open();
59  var command = Instance.CreateCommand();
60  command.Connection = connection;
61  command.CommandText = string.Format(CreateDatabaseSql, Config.Name);
62  command.Prepare();
63  connection.Close();
64  }
abstract IDbCommand CreateCommand()
override IDbConnection CreateGenericConnection()
Definition: MySqlFactory.cs:66
static SqlDatabaseFactory Instance
static IDatabaseConfiguration Config
override IDbConnection Ntp.Data.Provider.MySqlFactory.CreateGenericConnection ( )
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 66 of file MySqlFactory.cs.

67  {
68  return new MySqlConnection(BuildConnectionString(false));
69  }
static string BuildConnectionString(bool includeName=true)
override IDbDataParameter Ntp.Data.Provider.MySqlFactory.CreateParameter ( string  name,
object  value 
)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 71 of file MySqlFactory.cs.

72  {
73  return new MySqlParameter(name, value);
74  }
override string Ntp.Data.Provider.MySqlFactory.DateAddMinutes ( string  dateColumn,
string  minuteColumn 
)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 76 of file MySqlFactory.cs.

77  {
78  return $"{dateColumn} - interval {minuteColumn} minute";
79  }
override string Ntp.Data.Provider.MySqlFactory.PrepareCheckTableSql ( string  table)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 81 of file MySqlFactory.cs.

82  {
83  return PrepareSql(string.Format(CheckTableSql, Config.Name, table));
84  }
static IDatabaseConfiguration Config
override string PrepareSql(string sql)
Definition: MySqlFactory.cs:96
override string Ntp.Data.Provider.MySqlFactory.PrepareCreateTableSql ( string  sql)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 86 of file MySqlFactory.cs.

87  {
88  return PrepareSql(string.Format(sql, "INT NOT NULL AUTO_INCREMENT", " ENGINE=INNODB"));
89  }
override string PrepareSql(string sql)
Definition: MySqlFactory.cs:96
override string Ntp.Data.Provider.MySqlFactory.PrepareInsertSql ( string  sql)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 91 of file MySqlFactory.cs.

92  {
93  return PrepareSql(string.Format(sql, "SELECT LAST_INSERT_ID()"));
94  }
override string PrepareSql(string sql)
Definition: MySqlFactory.cs:96
override string Ntp.Data.Provider.MySqlFactory.PrepareSql ( string  sql)
inlinevirtual

Implements Ntp.Data.Provider.SqlDatabaseFactory.

Definition at line 96 of file MySqlFactory.cs.

97  {
98  return sql.Replace("[", string.Empty).Replace("]", string.Empty);
99  }

Member Data Documentation

const string Ntp.Data.Provider.MySqlFactory.CheckTableSql
private
Initial value:
=
"SELECT table_name " +
"FROM information_schema.tables " +
"WHERE table_schema = '{0}' " +
"AND table_name = '{1}';"

Definition at line 38 of file MySqlFactory.cs.

const string Ntp.Data.Provider.MySqlFactory.CreateDatabaseSql
private
Initial value:
=
"CREATE DATABASE IF NOT EXISTS {0};"

Definition at line 35 of file MySqlFactory.cs.


The documentation for this class was generated from the following file: