프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / ID2Info.cs @ abc4250b

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

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.IO;
7

    
8
namespace ID2PSN
9
{
10
    public enum ID2DB_Type
11
    {
12
        None, //ID2와 숫자 동일하게 하기위해 None은 의미 없음
13
        MSSQL,
14
        SQLite
15
    }
16

    
17
    public class ID2Info
18
    {
19
        private static ID2Info projectInfo;
20
        private string _DefaultPath;
21
        private string _Name;
22
        private string _DBFilePath;
23
        private string _TempDirPath;
24
        private string _ImageDirPath;
25
        private string _SvgImageDirPath;
26
        private string _ProgramName;
27
        private string _ProgramErrorName;
28
        private ID2DB_Type _ID2DBType;
29

    
30
        public string ServerIP { get; set; }
31
        public string Port { get; set; }
32
        public string DBUser { get; set; }
33
        public string DBPassword { get; set; }
34
        public string Database { get; set; }
35

    
36
        public string DefaultPath {
37
            get { return _DefaultPath; }
38
            set {
39
                _DefaultPath = value;
40
                _Name = Path.GetFileName(value);
41
                _DBFilePath = value + @"\db\ITI_PID.db";
42
                _TempDirPath = value + @"\Temp\";
43
                _ImageDirPath = value + @"\image\";
44
                _SvgImageDirPath = value + @"\svg\";
45
            }
46
        }
47

    
48
        public string ProgramName
49
        {
50
            get { return _ProgramName; }
51
            set { _ProgramName = value; }
52
        }
53

    
54
        public ID2DB_Type ID2DBType
55
        {
56
            get { return _ID2DBType; }
57
            set { _ID2DBType = value; }
58
        }
59

    
60
        public string Name
61
        {
62
            get { return _Name; }
63
        }
64

    
65
        public string DBFilePath
66
        {
67
            get { return _DBFilePath; }
68
        }
69

    
70
        public string TempDirPath
71
        {
72
            get { return _TempDirPath; }
73
        }
74

    
75
        public string ImageDirPath
76
        {
77
            get { return _ImageDirPath; }
78
        }
79

    
80
        public string SvgImageDirPath
81
        {
82
            get { return _SvgImageDirPath; }
83
        }
84

    
85
        public static ID2Info GetInstance()
86
        {
87
            if (projectInfo == null)
88
                projectInfo = new ID2Info();
89

    
90
            return projectInfo;
91
        }
92

    
93
        public IAbstractDatabase CreateConnection(ID2DB_Type type=ID2DB_Type.None)
94
        {
95
            if (type == ID2DB_Type.None)
96
            {
97
                if (this.ID2DBType == ID2DB_Type.SQLite)
98
                {
99
                    return new AppSQLiteDatabase() { FilePath = this.DBFilePath };
100
                }
101
                else if (this.ID2DBType == ID2DB_Type.MSSQL)
102
                {
103
                    return new AppMSSqlDatabase()
104
                    {
105
                        Host = this.ServerIP,
106
                        Id = this.DBUser,
107
                        Password = this.DBPassword,
108
                        Database = this.Database,
109
                        SqlAuthentication = AppMSSqlDatabase.SERVER_Authen
110
                    };
111
                }
112
            }
113
            else if(type == ID2DB_Type.SQLite)
114
            {
115
                return new AppSQLiteDatabase() { FilePath = this.DBFilePath };
116
            }
117

    
118
            throw new NotSupportedException();
119
        }
120
    }
121
}
클립보드 이미지 추가 (최대 크기: 500 MB)