프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (3.25 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
        {
38
            get { return _DefaultPath; }
39
            set
40
            {
41
                _DefaultPath = value;
42
                _Name = Path.GetFileName(value);
43
                _DBFilePath = value + @"\db\ITI_PID.db";
44
                _TempDirPath = value + @"\Temp\";
45
                _ImageDirPath = value + @"\image\";
46
                _SvgImageDirPath = value + @"\svg\";
47
            }
48
        }
49

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

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

    
62
        public string Name
63
        {
64
            get { return _Name; }
65
        }
66

    
67
        public string DBFilePath
68
        {
69
            get { return _DBFilePath; }
70
        }
71

    
72
        public string TempDirPath
73
        {
74
            get { return _TempDirPath; }
75
        }
76

    
77
        public string ImageDirPath
78
        {
79
            get { return _ImageDirPath; }
80
        }
81

    
82
        public string SvgImageDirPath
83
        {
84
            get { return _SvgImageDirPath; }
85
        }
86

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

    
92
            return projectInfo;
93
        }
94

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

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