프로젝트

일반

사용자정보

개정판 d327a608

IDd327a6081c08f7db300ce67ba52cea2dc5f26be4
상위 465c8b6e
하위 c7db500b

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #1223 : project info 정리 및 converter form 개발

Change-Id: I3e9d87f2f2218a1c1ace702e9f62b8d08beb2e2d

차이점 보기:

DTI_PID/APIDConverter/DB/Project_DB.cs
179 179

  
180 180
            return dt;
181 181
        }
182
        public static DataTable SelectSymbolType()
183
        {
184
            DataTable dt = new DataTable();
185
            Project_Info projectInfo = Project_Info.GetInstance();
186
            if (projectInfo.DBType == ID2DB_Type.SQLite)
187
            {
188
                using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
189
                {
190
                    try
191
                    {
192
                        connection.Open();
193
                        using (SQLiteCommand cmd = connection.CreateCommand())
194
                        {
195
                            cmd.CommandText = string.Format("SELECT * FROM {0}", SymbolType_TABLE);
196
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
197
                                dt.Load(dr);
198
                        }
199
                        connection.Close();
200
                    }
201
                    catch (Exception ex)
202
                    {
203
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
204
                    }
205
                    finally
206
                    {
207
                        connection.Dispose();
208
                    }
209
                }
210
            }
211
            else if (projectInfo.DBType == ID2DB_Type.MSSQL)
212
            {
213
                using (SqlConnection connection = GetSqlConnection())
214
                {
215
                    try
216
                    {
217
                        if (connection != null && connection.State == ConnectionState.Open)
218
                        {
219
                            using (SqlCommand cmd = connection.CreateCommand())
220
                            {
221
                                cmd.CommandText = string.Format("SELECT * FROM {0}", SymbolType_TABLE);
222
                                using (SqlDataReader dr = cmd.ExecuteReader())
223
                                    dt.Load(dr);
224
                            }
225
                            connection.Close();
226
                        }
227
                    }
228
                    catch (Exception ex)
229
                    {
230
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
231
                    }
232
                    finally
233
                    {
234
                        if (connection != null)
235
                            connection.Dispose();
236
                    }
237
                }
238
            }
182 239

  
240
            return dt;
241
        }
183 242
    }
184 243
}
DTI_PID/APIDConverter/Form/APIDConverter.Designer.cs
43 43
            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
44 44
            this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
45 45
            this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
46
            this.btnRefresh = new DevExpress.XtraEditors.SimpleButton();
47
            this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
48
            this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
46 49
            ((System.ComponentModel.ISupportInitialize)(this.ribbonControl)).BeginInit();
47 50
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
48 51
            this.layoutControl1.SuspendLayout();
......
54 57
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
55 58
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
56 59
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
60
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
61
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
57 62
            this.SuspendLayout();
58 63
            // 
59 64
            // ribbonControl
......
77 82
            // 
78 83
            // layoutControl1
79 84
            // 
85
            this.layoutControl1.Controls.Add(this.btnRefresh);
80 86
            this.layoutControl1.Controls.Add(this.btnRun);
81 87
            this.layoutControl1.Controls.Add(this.gridControlConverter);
82 88
            this.layoutControl1.Controls.Add(this.btnLoadFile);
......
144 150
            this.layoutControlItem2,
145 151
            this.layoutControlItem1,
146 152
            this.emptySpaceItem1,
147
            this.layoutControlItem3});
153
            this.layoutControlItem3,
154
            this.layoutControlItem4,
155
            this.emptySpaceItem2});
148 156
            this.layoutControlGroup1.Location = new System.Drawing.Point(0, 0);
149 157
            this.layoutControlGroup1.Name = "layoutControlGroup1";
150 158
            this.layoutControlGroup1.Size = new System.Drawing.Size(836, 417);
......
174 182
            // emptySpaceItem1
175 183
            // 
176 184
            this.emptySpaceItem1.AllowHotTrack = false;
177
            this.emptySpaceItem1.Location = new System.Drawing.Point(114, 0);
185
            this.emptySpaceItem1.Location = new System.Drawing.Point(235, 0);
178 186
            this.emptySpaceItem1.Name = "emptySpaceItem1";
179
            this.emptySpaceItem1.Size = new System.Drawing.Size(615, 40);
187
            this.emptySpaceItem1.Size = new System.Drawing.Size(494, 40);
180 188
            this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
181 189
            // 
182 190
            // layoutControlItem3
......
191 199
            this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0);
192 200
            this.layoutControlItem3.TextVisible = false;
193 201
            // 
202
            // btnRefresh
203
            // 
204
            this.btnRefresh.ImageOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("btnRefresh.ImageOptions.SvgImage")));
205
            this.btnRefresh.Location = new System.Drawing.Point(156, 58);
206
            this.btnRefresh.Name = "btnRefresh";
207
            this.btnRefresh.Size = new System.Drawing.Size(99, 36);
208
            this.btnRefresh.StyleController = this.layoutControl1;
209
            this.btnRefresh.TabIndex = 7;
210
            this.btnRefresh.Text = "  Refresh  ";
211
            // 
212
            // layoutControlItem4
213
            // 
214
            this.layoutControlItem4.Control = this.btnRefresh;
215
            this.layoutControlItem4.Location = new System.Drawing.Point(132, 0);
216
            this.layoutControlItem4.MaxSize = new System.Drawing.Size(103, 40);
217
            this.layoutControlItem4.MinSize = new System.Drawing.Size(103, 40);
218
            this.layoutControlItem4.Name = "layoutControlItem4";
219
            this.layoutControlItem4.Size = new System.Drawing.Size(103, 40);
220
            this.layoutControlItem4.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
221
            this.layoutControlItem4.TextSize = new System.Drawing.Size(0, 0);
222
            this.layoutControlItem4.TextVisible = false;
223
            // 
224
            // emptySpaceItem2
225
            // 
226
            this.emptySpaceItem2.AllowHotTrack = false;
227
            this.emptySpaceItem2.Location = new System.Drawing.Point(114, 0);
228
            this.emptySpaceItem2.Name = "emptySpaceItem2";
229
            this.emptySpaceItem2.Size = new System.Drawing.Size(18, 40);
230
            this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
231
            // 
194 232
            // APIDConverter
195 233
            // 
196 234
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
......
214 252
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
215 253
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
216 254
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
255
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
256
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
217 257
            this.ResumeLayout(false);
218 258
            this.PerformLayout();
219 259

  
......
233 273
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
234 274
        private DevExpress.XtraEditors.SimpleButton btnRun;
235 275
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3;
276
        private DevExpress.XtraEditors.SimpleButton btnRefresh;
277
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
278
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
236 279
    }
237 280
}
DTI_PID/APIDConverter/Form/APIDConverter.cs
7 7
using System.Text;
8 8
using System.Threading.Tasks;
9 9
using System.Windows.Forms;
10
using DevExpress.XtraEditors.Repository;
11
using DevExpress.XtraEditors.Controls;
12
using DevExpress.XtraEditors;
13
using System.Globalization;
14
using System.Threading;
15
using System.IO;
10 16
using AVEVA.PID.CustomizationUtility.DB;
11 17
using AVEVA.PID.CustomizationUtility.Model;
12 18
using AVEVA.PID.CustomizationUtility.Properties;
......
18 24
        public APIDConverter()
19 25
        {
20 26
            InitializeComponent();
27
            InitUsedDataTable();
28
            InitGridControl();
21 29
        }
22 30

  
23 31
        DataTable ID2SymbolTypeTable = null;
32
        private DataTable _ConverterDT = new DataTable();
33
        public List<Document> Documents = new List<Document>();
34

  
35
        private void InitUsedDataTable()
36
        {
37
            // Converter Table
38
            DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
39
            col.Caption = "Drawing File Name";
40
            col = _ConverterDT.Columns.Add("colDrawingFilePath");
41
            col.Caption = "DrawingFilePath";
42
            col = _ConverterDT.Columns.Add("colUnit");
43
            col.Caption = "Unit";
44
            col = _ConverterDT.Columns.Add("colTemplate");
45
            col.Caption = "Template";
46
            col = _ConverterDT.Columns.Add("colDrawingNumber");
47
            col.Caption = "Drawing Number";
48
            col = _ConverterDT.Columns.Add("colDrawingName");
49
            col.Caption = "Drawing Name";
50
            col = _ConverterDT.Columns.Add("colStatus");
51
            col.Caption = "Status";
52
            col = _ConverterDT.Columns.Add("colUID");
53
        }
54

  
55
        private void InitGridControl()
56
        {
57
            #region Converter Page
58
            gridViewConverter.OptionsSelection.MultiSelect = true;
59
            gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
60

  
61
            gridControlConverter.DataSource = _ConverterDT;
62

  
63
            gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
64
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
65
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
66
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
67
            gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
68
            gridViewConverter.Columns["colUID"].Visible = false;
69

  
70
            gridViewConverter.BestFitColumns();
71
            #endregion
72
        }
73

  
24 74

  
25 75
        private void btnLoadFile_Click(object sender, EventArgs e)
26 76
        {
......
36 86
                foreach (var fileName in dia.FileNames)
37 87
                {
38 88
                    Document document = new Document(fileName, ID2SymbolTypeTable);
39

  
89
                    if (document.Enable)
90
                    {
91
                        Documents.Add(document);
92
                    }
40 93
                }
41 94
            }
42 95
        }
......
47 100
            if (!project.Enable)
48 101
            {
49 102
                MessageBox.Show("Check Project Setting!", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Warning);
103
                DialogResult = DialogResult.Cancel;
50 104
            }
51 105
            else
52 106
            {
53
                ID2SymbolTypeTable = Project_DB.SelectID2SymbolTable();
107
                ID2SymbolTypeTable = Project_DB.SelectSymbolType();
54 108
            }
55 109
        }
56 110
    }
DTI_PID/APIDConverter/Form/APIDConverter.resx
121 121
    <value>17, 17</value>
122 122
  </metadata>
123 123
  <assembly alias="DevExpress.Data.v18.2" name="DevExpress.Data.v18.2, Version=18.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
124
  <data name="btnRefresh.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v18.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
125
    <value>
126
        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjE4LjIsIFZlcnNpb249MTguMi43
127
        LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
128
        dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAFYDAAAC77u/
129
        PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
130
        IHZpZXdCb3g9IjAgMCAzMiAzMiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv
131
        MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBlbmFibGUt
132
        YmFja2dyb3VuZD0ibmV3IDAgMCAzMiAzMiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgaWQ9IlJlZnJlc2gi
133
        Pg0KICA8ZyBvcGFjaXR5PSIwLjUiIGNsYXNzPSJzdDAiPg0KICAgIDxwYXRoIGQ9Ik0xMCwxMEg2VjZo
134
        NFYxMHogTTI0LDZIMTJ2NGgxMlY2eiBNMTAsMTJINnYxMmg0VjEyeiIgZmlsbD0iIzExNzdENyIgb3Bh
135
        Y2l0eT0iMC41IiBjbGFzcz0iQmx1ZSIgLz4NCiAgPC9nPg0KICA8cGF0aCBkPSJNMzAsMTZ2NmgtMC4x
136
        aC0ySDI0bDIuNS0yLjVDMjUuNiwxOC42LDI0LjQsMTgsMjMsMThjLTIuNCwwLTQuNCwxLjctNC45LDRo
137
        LTJjMC41LTMuNCwzLjQtNiw2LjktNiAgYzEuOSwwLDMuNywwLjgsNC45LDIuMUwzMCwxNnogTTIzLDI4
138
        Yy0xLjQsMC0yLjYtMC42LTMuNS0xLjVMMjIsMjRoLTMuOWgtMkgxNnY2bDIuMS0yLjFjMS4zLDEuMywz
139
        LDIuMSw0LjksMi4xICBjMy41LDAsNi40LTIuNiw2LjktNmgtMkMyNy40LDI2LjMsMjUuNCwyOCwyMywy
140
        OHoiIGZpbGw9IiMwMzlDMjMiIGNsYXNzPSJHcmVlbiIgLz4NCiAgPHBhdGggZD0iTTI3LDJIM0MyLjQs
141
        MiwyLDIuNCwyLDN2MjRjMCwwLjYsMC40LDEsMSwxaDExdi0ySDRWNGgyMnYxMC41YzAuNywwLjMsMS40
142
        LDAuNiwyLDFWM0MyOCwyLjQsMjcuNiwyLDI3LDJ6IiBmaWxsPSIjNzI3MjcyIiBjbGFzcz0iQmxhY2si
143
        IC8+DQo8L3N2Zz4L
144
</value>
145
  </data>
124 146
  <data name="btnRun.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v18.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
125 147
    <value>
126 148
        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjE4LjIsIFZlcnNpb249MTguMi43
DTI_PID/APIDConverter/Form/MappingForm.cs
26 26
            if (!project.Enable)
27 27
            {
28 28
                MessageBox.Show("Check Project Setting!", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Warning);
29
                DialogResult = DialogResult.Cancel;
29 30
            }
30 31
        }
31 32
    }
DTI_PID/APIDConverter/Log.cs
9 9
{
10 10
    public static class Log
11 11
    {
12
        private static readonly string Path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\SPPID Converter.log";
12
        private static readonly string Path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\APID Converter.log";
13 13

  
14 14
        public static void Write(string text)
15 15
        {
DTI_PID/APIDConverter/PIDCustomization.cs
91 91
            SetColorForEntity(BlockId,0);// white color
92 92
        }
93 93

  
94
        public static void GetProjectInfo()
95
        {
96
            Project_Info _ProjectInfo = Project_Info.GetInstance();
97
            _ProjectInfo.DefaultPath = Settings.Default.ProjectPath;
98
            _ProjectInfo.DBType = (ID2DB_Type)Settings.Default.ProjectDBType;
99
            _ProjectInfo.ServerIP = Settings.Default.ProjectServerIP;
100
            _ProjectInfo.Port = Settings.Default.ProjectPort;
101
            _ProjectInfo.DBUser = Settings.Default.ProjectDBUser;
102
            _ProjectInfo.DBPassword = Settings.Default.ProjectDBPassword;
103

  
104
            if (Project_DB.ConnTestAndCreateTable())
105
            {
106
                _ProjectInfo.Enable = true;
107
            }
108
            else
109
            {
110
                _ProjectInfo.Enable = false;
111
                MessageBox.Show("Fail project setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
112
            }
113
        }
94 114
        #region Command
95 115
        /// <summary>
96 116
        /// This is test command which gives the idea regarding selection of an entity and assigning different color to it
......
98 118
        [CommandMethod("APIDConverter")]
99 119
        public static void APIDConverter()
100 120
        {
121
            GetInstance();
101 122
            ConverterRibbonUI.InitUI();
123
            GetProjectInfo();
102 124
        }
103 125
        [CommandMethod("AC")]
104 126
        public static void AC()
105 127
        {
106 128
            GetInstance();
107 129
            ConverterRibbonUI.InitUI();
130
            GetProjectInfo();
108 131
        }
109 132
        [CommandMethod("ConverterForm")]
110 133
        public static void ConverterForm()
......
139 162
                    _ProjectInfo.Enable = false;
140 163
                    MessageBox.Show("Fail project setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
141 164
                }
142
                    
143 165
            }
144 166
        }
145 167
        [CommandMethod("MappingForm")]

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)