프로젝트

일반

사용자정보

개정판 c7db500b

IDc7db500b482e99105d730db90533221e7fb11775
상위 d327a608
하위 b244f30e, 05851873, 0169b3c7

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

dev issue #1226 : dev converter form

Change-Id: I460e2fe84c8d64a716b3fd2704154bcebe3f47b6

차이점 보기:

DTI_PID/APIDConverter/DB/Project_DB.cs
239 239

  
240 240
            return dt;
241 241
        }
242
        public static DataTable SelectDrawings()
243
        {
244
            DataTable dt = new DataTable();
245
            Project_Info projectInfo = Project_Info.GetInstance();
246
            if (projectInfo.DBType == ID2DB_Type.SQLite)
247
            {
248
                using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
249
                {
250
                    try
251
                    {
252
                        connection.Open();
253
                        using (SQLiteCommand cmd = connection.CreateCommand())
254
                        {
255
                            cmd.CommandText = string.Format("SELECT * FROM {0}", "Drawings");
256
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
257
                                dt.Load(dr);
258
                        }
259
                        connection.Close();
260
                    }
261
                    catch (Exception ex)
262
                    {
263
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
264
                    }
265
                    finally
266
                    {
267
                        connection.Dispose();
268
                    }
269
                }
270
            }
271
            else if (projectInfo.DBType == ID2DB_Type.MSSQL)
272
            {
273
                using (SqlConnection connection = GetSqlConnection())
274
                {
275
                    try
276
                    {
277
                        if (connection != null && connection.State == ConnectionState.Open)
278
                        {
279
                            using (SqlCommand cmd = connection.CreateCommand())
280
                            {
281
                                cmd.CommandText = string.Format("SELECT * FROM {0}", "Drawings");
282
                                using (SqlDataReader dr = cmd.ExecuteReader())
283
                                    dt.Load(dr);
284
                            }
285
                            connection.Close();
286
                        }
287
                    }
288
                    catch (Exception ex)
289
                    {
290
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
291
                    }
292
                    finally
293
                    {
294
                        if (connection != null)
295
                            connection.Dispose();
296
                    }
297
                }
298
            }
299

  
300
            return dt;
301
        }
242 302
    }
243 303
}
DTI_PID/APIDConverter/Form/APIDConverter.Designer.cs
103 103
            this.btnRun.StyleController = this.layoutControl1;
104 104
            this.btnRun.TabIndex = 6;
105 105
            this.btnRun.Text = "  Run  ";
106
            this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
106 107
            // 
107 108
            // gridControlConverter
108 109
            // 
......
208 209
            this.btnRefresh.StyleController = this.layoutControl1;
209 210
            this.btnRefresh.TabIndex = 7;
210 211
            this.btnRefresh.Text = "  Refresh  ";
212
            this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
211 213
            // 
212 214
            // layoutControlItem4
213 215
            // 
DTI_PID/APIDConverter/Form/APIDConverter.cs
31 31
        DataTable ID2SymbolTypeTable = null;
32 32
        private DataTable _ConverterDT = new DataTable();
33 33
        public List<Document> Documents = new List<Document>();
34
        private Dictionary<string, Document> _DicDocuments = new Dictionary<string, Document>();
34 35

  
35 36
        private void InitUsedDataTable()
36 37
        {
......
39 40
            col.Caption = "Drawing File Name";
40 41
            col = _ConverterDT.Columns.Add("colDrawingFilePath");
41 42
            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 43
            col = _ConverterDT.Columns.Add("colStatus");
51 44
            col.Caption = "Status";
52 45
            col = _ConverterDT.Columns.Add("colUID");
......
60 53

  
61 54
            gridControlConverter.DataSource = _ConverterDT;
62 55

  
63
            gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
64 56
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
65
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
66 57
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
67 58
            gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
68 59
            gridViewConverter.Columns["colUID"].Visible = false;
......
86 77
                foreach (var fileName in dia.FileNames)
87 78
                {
88 79
                    Document document = new Document(fileName, ID2SymbolTypeTable);
89
                    if (document.Enable)
80

  
81
                    DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
82
                    if (rows.Length == 0)
90 83
                    {
91
                        Documents.Add(document);
84
                        DataRow row = _ConverterDT.NewRow();
85
                        row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
86
                        row["colDrawingFilePath"] = fileName;
87
                        if (document.Enable)
88
                            row["colStatus"] = "Ready";
89
                        else
90
                            row["colStatus"] = "Error";
91
                        row["colUID"] = "";
92

  
93
                        _ConverterDT.Rows.Add(row);
94

  
95
                        if (document.Enable)
96
                            gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
92 97
                    }
98
                    else
99
                    {
100
                        foreach (DataRow row in rows)
101
                        {
102
                            if (document.Enable)
103
                                row["colStatus"] = "Ready";
104
                            else
105
                                row["colStatus"] = "Error";
106
                           
107
                            if (document.Enable)
108
                                gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
109
                        }
110
                    }
111

  
112
                    if (!_DicDocuments.ContainsKey(fileName))
113
                        _DicDocuments.Add(fileName, null);
114

  
115
                    _DicDocuments[fileName] = document;
93 116
                }
94 117
            }
95 118
        }
......
107 130
                ID2SymbolTypeTable = Project_DB.SelectSymbolType();
108 131
            }
109 132
        }
133

  
134
        private void btnRun_Click(object sender, EventArgs e)
135
        {
136
            if (gridViewConverter.GetSelectedRows().Length == 0)
137
            {
138
                MessageBox.Show("Select Document", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Warning);
139
                return;
140
            }
141

  
142
            DataTable tDrawing = Project_DB.SelectDrawings();
143
            Documents.Clear();
144
            foreach (int rowHandle in gridViewConverter.GetSelectedRows())
145
            {
146
                string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
147

  
148
                DataRow[] rows = tDrawing.Select(string.Format("NAME = '{0}'", Path.GetFileNameWithoutExtension(_FilePath) + ".png"));
149
                if (rows.Length != 1)
150
                    continue;
151

  
152
                Document document = _DicDocuments[_FilePath];
153
                document.UID = rows[0]["UID"].ToString();
154
                Documents.Add(document);
155
            }
156

  
157
            DialogResult = DialogResult.OK;
158
        }
159

  
160
        private void btnRefresh_Click(object sender, EventArgs e)
161
        {
162
            foreach (DataRow row in _ConverterDT.Rows)
163
            {
164
                string fileName = row["colDrawingFilePath"].ToString();
165
                Document document = new Document(fileName, ID2SymbolTypeTable);
166

  
167
                row["colDrawingNumber"] = document.DWGNAME;
168
                row["colDrawingName"] = document.DWGNAME;
169
                if (document.Enable)
170
                    row["colStatus"] = "Ready";
171
                else
172
                    row["colStatus"] = "Error";
173

  
174
                if (!_DicDocuments.ContainsKey(fileName))
175
                    _DicDocuments.Add(fileName, null);
176

  
177
                _DicDocuments[fileName] = document;
178

  
179
                if (document.Enable)
180
                    gridViewConverter.SelectRow(gridViewConverter.GetRowHandle(_ConverterDT.Rows.IndexOf(row)));
181
            }
182
        }
110 183
    }
111 184
}

내보내기 Unified diff

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