개정판 e00e891d
dev issue #000 : end mapping
Change-Id: I66da9a36ddc64be0951b68927751ea4089b8db40
DTI_PID/BaseModel/Project_DB.cs | ||
---|---|---|
14 | 14 |
const string SPPID_DB_INFO_TABLE = "T_SPPID_CONNECTION_INFO"; |
15 | 15 |
const string SPPID_SYMBOL_MAPPING_TABLE = "T_SPPID_SYMBOL_MAPPING"; |
16 | 16 |
const string SPPID_ATTRIBUTE_MAPPING_TABLE = "T_SPPID_ATTRIBUTE_MAPPING"; |
17 |
const string SPPID_ETC_SETTING_TABLE = "T_SPPID_ETC_SETTING_TABLE"; |
|
17 | 18 |
|
18 | 19 |
const string LineProperties_TABLE = "LineProperties"; |
19 | 20 |
const string LineTypes_TABLE = "LineTypes"; |
... | ... | |
87 | 88 |
Project_Info projectInfo = Project_Info.GetInstance(); |
88 | 89 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
89 | 90 |
{ |
90 |
|
|
91 | 91 |
try |
92 | 92 |
{ |
93 | 93 |
connection.Open(); |
... | ... | |
112 | 112 |
return dt; |
113 | 113 |
} |
114 | 114 |
|
115 |
public static bool SaveETCSetting(string jsonString) |
|
116 |
{ |
|
117 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
118 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
119 |
{ |
|
120 |
|
|
121 |
try |
|
122 |
{ |
|
123 |
connection.Open(); |
|
124 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
125 |
{ |
|
126 |
cmd.CommandText = string.Format("DELETE FROM {0}", SPPID_ETC_SETTING_TABLE); |
|
127 |
cmd.ExecuteNonQuery(); |
|
128 |
|
|
129 |
cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@jsonString)", SPPID_ETC_SETTING_TABLE); |
|
130 |
cmd.Parameters.AddWithValue("@jsonString", jsonString); |
|
131 |
cmd.ExecuteNonQuery(); |
|
132 |
} |
|
133 |
connection.Close(); |
|
134 |
} |
|
135 |
catch (Exception ex) |
|
136 |
{ |
|
137 |
return false; |
|
138 |
} |
|
139 |
finally |
|
140 |
{ |
|
141 |
connection.Dispose(); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
return true; |
|
146 |
} |
|
147 |
|
|
148 |
public static DataTable SelectETCSetting() |
|
149 |
{ |
|
150 |
DataTable dt = new DataTable(); |
|
151 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
152 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
153 |
{ |
|
154 |
try |
|
155 |
{ |
|
156 |
connection.Open(); |
|
157 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
158 |
{ |
|
159 |
cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_ETC_SETTING_TABLE); |
|
160 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
161 |
dt.Load(dr); |
|
162 |
} |
|
163 |
connection.Close(); |
|
164 |
} |
|
165 |
catch (Exception ex) |
|
166 |
{ |
|
167 |
|
|
168 |
} |
|
169 |
finally |
|
170 |
{ |
|
171 |
connection.Dispose(); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
return dt; |
|
176 |
} |
|
177 |
|
|
115 | 178 |
private static void CreateTable(SQLiteConnection connection) |
116 | 179 |
{ |
117 | 180 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
... | ... | |
127 | 190 |
cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_DB_INFO_TABLE); |
128 | 191 |
cmd.ExecuteNonQuery(); |
129 | 192 |
} |
193 |
if (dt.Select(string.Format("NAME = '{0}'", SPPID_ETC_SETTING_TABLE)).Length == 0) |
|
194 |
{ |
|
195 |
cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_ETC_SETTING_TABLE); |
|
196 |
cmd.ExecuteNonQuery(); |
|
197 |
} |
|
130 | 198 |
if (dt.Select(string.Format("NAME = '{0}'", SPPID_SYMBOL_MAPPING_TABLE)).Length == 0) |
131 | 199 |
{ |
132 | 200 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT, SPPID_SYMBOL_PATH TEXT)", SPPID_SYMBOL_MAPPING_TABLE); |
내보내기 Unified diff