hytos / ID2.Manager / ID2.Manager.Controller / Controllers / BaseController.cs @ 00d11333
이력 | 보기 | 이력해설 | 다운로드 (1.98 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
|
7 |
using System.Configuration; |
8 |
using System.IO; |
9 |
|
10 |
using ID2.Manager.Dapper; |
11 |
using ID2.Manager.Data.Models; |
12 |
|
13 |
namespace ID2.Manager.Controller.Controllers |
14 |
{ |
15 |
public class BaseController |
16 |
{ |
17 |
public Exception Exception; |
18 |
|
19 |
public readonly string _MSSQLCONNSTR; |
20 |
public readonly string _SQLITECONNSTR; |
21 |
public readonly string _MARKUSCONNSTR; |
22 |
public readonly string _ID2CONNSTR; |
23 |
|
24 |
public BaseController() : this(null) { } |
25 |
|
26 |
public BaseController(ID2ProjectInfo id2Info) |
27 |
{ |
28 |
this._MSSQLCONNSTR = ConfigurationManager.ConnectionStrings["ID2Manager"].ConnectionString; |
29 |
this._SQLITECONNSTR = String.Format(ConfigurationManager.AppSettings["ID2SQLite"], Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ConfigurationManager.AppSettings["ID2SQLiteInfo"])); |
30 |
this._MARKUSCONNSTR = ConfigurationManager.ConnectionStrings["Markus"].ToString(); |
31 |
|
32 |
if (id2Info == null || id2Info.Id <= 0) |
33 |
{ |
34 |
this._ID2CONNSTR = string.Empty; |
35 |
} |
36 |
else |
37 |
{ |
38 |
DatabaseType DBType = (DatabaseType)Enum.Parse(typeof(DatabaseType), id2Info.DBTypeName.ToUpper()); |
39 |
switch (DBType) |
40 |
{ |
41 |
case DatabaseType.MSSQL: |
42 |
this._ID2CONNSTR = String.Format(ConfigurationManager.ConnectionStrings["ID2Project"].ConnectionString, id2Info.Host, id2Info.DBPath, id2Info.User, id2Info.Password); |
43 |
break; |
44 |
case DatabaseType.SQLITE: |
45 |
this._ID2CONNSTR = String.Format(ConfigurationManager.AppSettings["ID2SQLite"], id2Info.DBPath); |
46 |
break; |
47 |
default: |
48 |
this._ID2CONNSTR = string.Empty; |
49 |
break; |
50 |
} |
51 |
} |
52 |
} |
53 |
} |
54 |
} |