프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Program.cs @ 0fe04b33

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

1
using System;
2
using System.Collections.Generic;
3
using System.Data;
4
using System.IO;
5
using System.Linq;
6
using System.Threading.Tasks;
7
using System.Windows.Forms;
8

    
9
namespace ID2PSN
10
{
11
    static class Program
12
    {
13
        /// <summary>
14
        /// 해당 애플리케이션의 주 진입점입니다.
15
        /// </summary>
16
        [STAThread]
17
        static void Main(string[] args)
18
        {
19
            if (!SingleInstance.Start("ecf2ed2e-1a3f-4926-a561-512857785805"))
20
            {
21
                return;
22
            }
23

    
24
            ID2Info info = ID2Info.GetInstance();
25
            DataTable projectTable = null;
26
            try
27
            {
28
                //string path = Application.StartupPath + @"\project.txt";
29
                //if (System.IO.File.Exists(path))
30
                //{
31
                //    ID2Info info = ID2Info.GetInstance();
32
                //    info.DefaultPath = File.ReadAllLines(path)[0];
33
                //}
34

    
35
#if DEBUG
36
                //info.DefaultPath = @"E:\DOFTECH\10.PSN\REB";
37
                //info.DefaultPath = @"E:\DOFTECH\10.PSN\SampleProject_규호";
38
                //info.DefaultPath = @"D:\Projects\dd\21100497014_REB";
39
                args = new string[1];
40
                 //args[0] = @"E:\DOFTECH\10.PSN\REB☆■☆PSN";
41
                
42
                args[0] = @"Z:\ID2_Project\REB☆■☆PSN";
43
#endif
44

    
45
                if (args.Length > 0)
46
                {
47
                    //이름 변경
48
                    string[] result = args[0].Split(new string[] { "☆■☆" }, StringSplitOptions.None);
49
                    if (result.Length > 0)
50
                    {
51
                        info.DefaultPath = result[0];
52
                        if (result.Length > 1)
53
                            info.ProgramName = result[1];
54
                        else
55
                            info.ProgramName = "PSN";
56
                    }
57

    
58
                    //DB Type 확인
59
                    projectTable = DB.GetProject();
60
                    DataRow dr = projectTable.Select(string.Format("Path = '{0}'", result[0].Replace(@"\", @"/"))).FirstOrDefault();
61
                    //2는 mssql 1은 sqlite
62
                    if (Convert.ToInt32(dr.Field<long>("DBTypes_UID")) == 1)
63
                        info.ID2DBType = ID2DB_Type.SQLite;
64
                    else if (Convert.ToInt32(dr.Field<long>("DBTypes_UID")) == 2)
65
                    {
66
                        info.ID2DBType = ID2DB_Type.MSSQL;
67
                        info.ServerIP = dr.Field<string>("Host");
68
                        //2021-11-03 ID2는 무조건 기본포트 쓴다고 함
69
                        //info.Port = "3389"; 
70
                        info.DBUser = dr.Field<string>("User");
71
                        info.DBPassword = dr.Field<string>("Password");
72
                        //info.DefaultPath = dr.Field<string>("Name");
73
                    }
74
                }
75

    
76
                if (DB.ConnTestAndCreateTable())
77
                {
78
                    Application.EnableVisualStyles();
79
                    Application.SetCompatibleTextRenderingDefault(false);
80
                    Application.Run(new MainForm()); 
81
                }
82
                else
83
                    MessageBox.Show("fail");
84
            }
85
            catch(Exception ex)
86
            {
87
                MessageBox.Show(ex.Message , "ID2 " + info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information);
88
            }
89
        }
90
    }
91
}