프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / BaseController.cs @ 00d11333

이력 | 보기 | 이력해설 | 다운로드 (1.98 KB)

1 8164f84e yoush97
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 91e72bfe yoush97
using System.IO;
9 8164f84e yoush97
10 fe57f64a yoush97
using ID2.Manager.Dapper;
11
using ID2.Manager.Data.Models;
12
13 8164f84e yoush97
namespace ID2.Manager.Controller.Controllers
14
{
15
    public class BaseController
16
    {
17 c112c3c3 taeseongkim
        public Exception Exception;
18
19 fe57f64a yoush97
        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 8164f84e yoush97
26 fe57f64a yoush97
        public BaseController(ID2ProjectInfo id2Info)
27 8164f84e yoush97
        {
28 fe57f64a yoush97
            this._MSSQLCONNSTR = ConfigurationManager.ConnectionStrings["ID2Manager"].ConnectionString;
29 91e72bfe yoush97
            this._SQLITECONNSTR = String.Format(ConfigurationManager.AppSettings["ID2SQLite"], Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ConfigurationManager.AppSettings["ID2SQLiteInfo"]));
30 fe57f64a yoush97
            this._MARKUSCONNSTR = ConfigurationManager.ConnectionStrings["Markus"].ToString();
31
32 91e72bfe yoush97
            if (id2Info == null || id2Info.Id <= 0)
33
            {
34
                this._ID2CONNSTR = string.Empty;
35
            }
36
            else
37 fe57f64a yoush97
            {
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 8164f84e yoush97
        }
53
    }
54
}
클립보드 이미지 추가 (최대 크기: 500 MB)