프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (2.04 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
using ID2.Manager.Common;
13

    
14
namespace ID2.Manager.Controller.Controllers
15
{
16
    public class BaseController
17
    {
18
        public Exception Exception;
19

    
20
        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

    
27
        public BaseController(ID2ProjectInfo id2Info)
28
        {
29
            this._MSSQLCONNSTR = ConfigurationManager.ConnectionStrings["ID2Manager"].ConnectionString;
30
            this._SQLITECONNSTR = Globals.GetProjectDBConnstr(); //String.Format(ConfigurationManager.AppSettings["ID2SQLite"], Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ConfigurationManager.AppSettings["ID2SQLiteInfo"]));
31
            this._MARKUSCONNSTR = ConfigurationManager.ConnectionStrings["Markus"].ToString();
32

    
33
            if (id2Info == null || id2Info.Id <= 0)
34
            {
35
                this._ID2CONNSTR = string.Empty;
36
            }
37
            else
38
            {
39
                DatabaseType DBType = (DatabaseType)Enum.Parse(typeof(DatabaseType), id2Info.DBTypeName.ToUpper());
40
                switch (DBType)
41
                {
42
                    case DatabaseType.MSSQL:
43
                        this._ID2CONNSTR = String.Format(ConfigurationManager.ConnectionStrings["ID2Project"].ConnectionString, id2Info.Host, id2Info.DBPath, id2Info.User, id2Info.Password);
44
                        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
        }
54
    }
55
}
클립보드 이미지 추가 (최대 크기: 500 MB)