프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / BaseController.cs @ d8bd4799

이력 | 보기 | 이력해설 | 다운로드 (2.06 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 b6abb7b8 yoush97
using ID2.Manager.Common;
13 fe57f64a yoush97
14 8164f84e yoush97
namespace ID2.Manager.Controller.Controllers
15
{
16
    public class BaseController
17
    {
18 c112c3c3 taeseongkim
        public Exception Exception;
19
20 fe57f64a yoush97
        public readonly string _MSSQLCONNSTR;
21
        public readonly string _SQLITECONNSTR;
22
        public readonly string _MARKUSCONNSTR;
23
        public readonly string _ID2CONNSTR;
24
25
        public BaseController() : this(null) { }
26 8164f84e yoush97
27 fe57f64a yoush97
        public BaseController(ID2ProjectInfo id2Info)
28 8164f84e yoush97
        {
29 fe57f64a yoush97
            this._MSSQLCONNSTR = ConfigurationManager.ConnectionStrings["ID2Manager"].ConnectionString;
30 b6abb7b8 yoush97
            this._SQLITECONNSTR = Globals.GetProjectDBConnstr(); //String.Format(ConfigurationManager.AppSettings["ID2SQLite"], Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ConfigurationManager.AppSettings["ID2SQLiteInfo"]));
31 fe57f64a yoush97
            this._MARKUSCONNSTR = ConfigurationManager.ConnectionStrings["Markus"].ToString();
32
33 91e72bfe yoush97
            if (id2Info == null || id2Info.Id <= 0)
34
            {
35
                this._ID2CONNSTR = string.Empty;
36
            }
37
            else
38 fe57f64a yoush97
            {
39
                DatabaseType DBType = (DatabaseType)Enum.Parse(typeof(DatabaseType), id2Info.DBTypeName.ToUpper());
40
                switch (DBType)
41
                {
42
                    case DatabaseType.MSSQL:
43 3295dabe yoush97
                        this._ID2CONNSTR = String.Format(ConfigurationManager.ConnectionStrings["ID2Project"].ConnectionString, id2Info.Host.Replace(":",","), id2Info.DBPath, id2Info.User, id2Info.Password);
44 fe57f64a yoush97
                        break;
45
                    case DatabaseType.SQLITE:
46
                        this._ID2CONNSTR = String.Format(ConfigurationManager.AppSettings["ID2SQLite"], id2Info.DBPath);
47
                        break;
48
                    default:
49
                        this._ID2CONNSTR = string.Empty;
50
                        break;
51
                }
52
            }
53 8164f84e yoush97
        }
54
    }
55
}
클립보드 이미지 추가 (최대 크기: 500 MB)