프로젝트

일반

사용자정보

개정판 ea54adc8

IDea54adc889946f2e7c3d539e8c535eccc0a9bb66
상위 ecf30b64
하위 dd5b2a95

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

dev issue #507 : edit query

Change-Id: I81f5d6356b39a584ca4214aedd5ccc6766edcf9b

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
1075 1075
                        drawingAttributeDT.Dispose();
1076 1076
                    }
1077 1077

  
1078
#if DEBUG
1079
                    foreach (LMAAttribute attribute1 in drawing.Attributes)
1080
                    {
1081
                        string name = attribute1.Name;
1082
                        object value = attribute1.get_Value();
1083
                    }
1084
#endif
1085

  
1086 1078
                    ReleaseCOMObjects(drawing);
1087 1079
                }
1088 1080

  
DTI_PID/SPPIDConverter/ConverterDocking.cs
210 210
            }
211 211
        }
212 212

  
213
        
214

  
213 215
        #region SPPID Utils
214 216

  
215 217
        #region Symmetry
......
1444 1446

  
1445 1447
        private void simpleButton1_Click(object sender, EventArgs e)
1446 1448
        {
1449
            SPPIDUtil.test();
1447 1450
            //Placement placement = new Placement();
1448 1451
            //LMADataSource dataSource = placement.PIDDataSource;
1449 1452
            //string a = "0A509911F33441A2AF088BFBA78B770D";
1450 1453
            //LMLabelPersist label = dataSource.GetLabelPersist(a);
1451 1454
            //label.set_XCoordinate(0.4);
1452 1455
            
1453
            foreach (AttributeSet attributes in application.ActiveDocument.AttributeSets)
1454
            {
1455
                foreach (Ingr.RAD2D.Attribute attribute in attributes)
1456
                {
1457
                    string name = attribute.Name;
1458
                    object value = attribute.GetValue();
1459
                    
1460
                }
1461
            }
1456

  
1457

  
1458

  
1459
            //LMOptionSettings
1460

  
1461

  
1462
            //LMAFilter filter = new LMAFilter();
1463
            //LMACriterion criterion = new LMACriterion();
1464
            //filter.ItemType = "Relationship";
1465
            //criterion.SourceAttributeName = "SP_DRAWINGID";
1466
            //criterion.Operator = "=";
1467
            //criterion.set_ValueAttribute(drawingID);
1468
            //filter.get_Criteria().Add(criterion);
1469

  
1470
            //LMRelationships relationships = new LMRelationships();
1471
            //relationships.Collect(dataSource, Filter: filter);
1472

  
1462 1473
        }
1463 1474

  
1464 1475
        private void AutoJoinPipeRun()
DTI_PID/SPPIDConverter/ConverterForm.cs
21 21
using Converter.SPPID.Util;
22 22
using Converter.SPPID.Form;
23 23
using Converter.SPPID.Model;
24
using Plaice;
25
using Llama;
26

  
24 27

  
25 28
namespace Converter.SPPID
26 29
{
......
52 55
        private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
53 56
        private List<AttributeMapping> attributeMappings = new List<AttributeMapping>();
54 57

  
58
        string TemplatePath;
59

  
55 60
        public ConverterForm()
56 61
        {
57 62
            InitializeComponent();
......
59 64
            CultureInfo culture = CultureInfo.GetCultureInfo("ko");
60 65
            Msg.Culture = culture;
61 66

  
67
            this._SPPIDUnitDT = SPPIDUtil.GetUnitInfo();
68
            TemplatePath = SPPIDUtil.T_OPTIONSETTING_Value("PID Template Path");
69

  
62 70
            InitUsedDataTable();
63 71
            InitGridControl();
64 72
            InitID2Project();
......
395 403
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
396 404
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
397 405

  
398
                string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
399 406
                if (!string.IsNullOrEmpty(TemplatePath))
400 407
                {
401 408
                    List<string> templateFiles = Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList();
......
403 410
                    comboBoxEditDefaultTemplate.Properties.Items.AddRange(templateFiles);
404 411
                }
405 412
                    
406

  
407
                if (_SPPIDUnitDT != null)
408
                {
409
                    _SPPIDUnitDT.Dispose();
410
                    _SPPIDUnitDT = null;
411
                }
412 413
                if (_SPPIDAttributeDT != null)
413 414
                {
414 415
                    _SPPIDAttributeDT.Dispose();
415 416
                    _SPPIDAttributeDT = null;
416 417
                }
417 418

  
418
                _SPPIDUnitDT = SPPID_DB.GetUnitTree();
419 419
                _SPPIDAttributeDT = SPPID_DB.GetSPPIDAttribute();
420 420
                if (_SPPIDAttributeDT != null)
421 421
                {
......
447 447

  
448 448
        private void InitSPPIDSymbolTreeTable()
449 449
        {
450
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
451

  
452 450
            try
453 451
            {
454 452
                _SPPIDSymbolPathDT = new DataTable();
......
457 455
                _SPPIDSymbolPathDT.Columns.Add("Name");
458 456
                _SPPIDSymbolPathDT.Columns.Add("FullPath");
459 457

  
460
                if (_SPPIDInfo.Enable)
461
                {
462
                    string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
463
                    DirectoryInfo info = new DirectoryInfo(symbolPath);
464
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
465
                    loop(info, "0", symbolPath);
466
                }
458
                string symbolPath = SPPIDUtil.T_OPTIONSETTING_Value("Catalog Explorer root path");
459
                DirectoryInfo info = new DirectoryInfo(symbolPath);
460
                _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
461
                loop(info, "0", symbolPath);
467 462
            }
468 463
            catch (Exception ex)
469 464
            {
DTI_PID/SPPIDConverter/DB/SPPID_DB.cs
94 94

  
95 95
            return bResult;
96 96
        }
97

  
98 97
        public static bool SetPlantDBSetting(SPPID_DBInfo dbInfo)
99 98
        {
100 99
            bool bResult = false;
......
171 170

  
172 171
            return bResult;
173 172
        }
174

  
175 173
        public static List<string> GetPlantList(SPPID_DBInfo dbInfo)
176 174
        {
177 175
            List<string> plantList = new List<string>();
......
216 214
            return plantList;
217 215
        }
218 216

  
219
        public static DataTable GetUnitTree()
220
        {
221
            DataTable dt = new DataTable();
222
            try
223
            {
224
                SPPID_DBInfo dbInfo = SPPID_DBInfo.GetInstance();
225

  
226
                if (dbInfo.DBType == "ORACLE")
227
                {
228
                    string connString = string.Format(oConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
229
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
230

  
231
                    using (OracleConnection conn = new OracleConnection(connString))
232
                    {
233
                        conn.Open();
234
                        if (conn.State == System.Data.ConnectionState.Open)
235
                        {
236
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
237
                                @"SELECT SP_ID, PARENTID, NAME
238
                                    FROM {0}.T_PLANTGROUP 
239
                                    START WITH PARENTID='-1'
240
                                    CONNECT BY PRIOR SP_ID=PARENTID", dbInfo.Plant);
241

  
242
                            using (OracleCommand cmd = new OracleCommand(sQuery, conn))
243
                            using (OracleDataAdapter adapter = new OracleDataAdapter())
244
                            {
245
                                adapter.SelectCommand = cmd;
246
                                adapter.Fill(dt);
247
                            }
248
                        }
249
                    }
250
                }
251
                else
252
                {
253

  
254
                }
255
            }
256
            catch (Exception ex)
257
            {
258
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
259
            }
260

  
261
            return dt;
262
        }
263

  
264
        public static string GetPlantPID_T_OPTIONSETTING_Value(string name)
265
        {
266
            string TemplatePath = string.Empty;
267
            SPPID_DBInfo dbInfo = SPPID_DBInfo.GetInstance();
268
            try
269
            {
270
                if (dbInfo.DBType == "ORACLE")
271
                {
272
                    string connString = string.Format(oConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
273
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
274

  
275
                    using (OracleConnection conn = new OracleConnection(connString))
276
                    {
277
                        conn.Open();
278
                        if (conn.State == System.Data.ConnectionState.Open)
279
                        {
280
                            using (OracleCommand cmd = new OracleCommand())
281
                            {
282
                                cmd.Connection = conn;
283
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT VALUE FROM {0}.T_OPTIONSETTING WHERE NAME = '{1}'", dbInfo.PlantPID, name);
284

  
285
                                using (OracleDataReader reader = cmd.ExecuteReader())
286
                                {
287
                                    while (reader.Read())
288
                                    {
289
                                        TemplatePath = reader["VALUE"].ToString();
290
                                        break;
291
                                    }
292
                                }
293
                            }
294
                        }
295
                    }
296
                }
297
                else
298
                {
299

  
300
                }
301

  
302
            }
303
            catch (Exception ex)
304
            {
305
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
306
            }
307

  
308
            return TemplatePath;
309
        }
310

  
311 217
        public static DataTable GetSPPIDAttribute()
312 218
        {
313 219
            List<string> attributes = new List<string>();
......
355 261

  
356 262
            return dt;
357 263
        }
358

  
359 264
        public static DataTable GetFluidSystemInfo(string operFluidCode)
360 265
        {
361 266
            List<string> attributes = new List<string>();
DTI_PID/SPPIDConverter/Form/MappingForm.cs
570 570
        {
571 571
            Cursor = Cursors.WaitCursor;
572 572
            Project_Info project_Info = Project_Info.GetInstance();
573
            string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
573
            string symbolPath = Util.SPPIDUtil.T_OPTIONSETTING_Value("Catalog Explorer root path");
574 574
            foreach (DataRow row in SPPIDSymbolPathDT.Rows)
575 575
            {
576 576
                if (row["FullPath"] != DBNull.Value && !string.IsNullOrEmpty((string)row["FullPath"]))
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs
10 10
using System.Windows.Forms;
11 11
using Converter.SPPID.Model;
12 12
using System.Drawing;
13
using Llama;
14
using System.Data;
15
using Plaice;
16
using Microsoft.VisualBasic;
13 17

  
14 18
namespace Converter.SPPID.Util
15 19
{
......
638 642

  
639 643
            return result;
640 644
        }
645
        public static void test()
646
        {
647
            Placement placement = new Placement();
648
            //placement.PIDApplyParameters()
649
            LMADataSource dataSource = new LMADataSource();
650
            
651
            LMAFilter filter = new LMAFilter();
652
            //LMACriterion criterion = new LMACriterion();
653
            filter.ItemType = "Label";
654
            //criterion.SourceAttributeName = "NAME";
655
            //criterion.Operator = "=";
656
            //criterion.set_ValueAttribute(name);
657
            //filter.get_Criteria().Add(criterion);
658
            _LMAItems items = dataSource.Collect("Label", Filter: filter);
659
            
660

  
661
            ReleaseCOMObjects(dataSource);
662
        }
663
        public static DataTable GetUnitInfo()
664
        {
665
            LMADataSource dataSource = new LMADataSource();
666
            LMUnits units = new LMUnits();
667
            units.Collect(dataSource);
668
            DataTable dt = new DataTable();
669
            dt.Columns.Add("LEVEL", typeof(string));
670
            dt.Columns.Add("SP_ID", typeof(string));
671
            dt.Columns.Add("PARENTID", typeof(string));
672
            dt.Columns.Add("NAME", typeof(string));
673
            foreach (LMUnit unit in units)
674
            {
675
                string dir = unit.get_Dir_Path();
676
                string[] array = dir.Split('\\');
677
                List<string> parents = new List<string>();
678
                string prevId = "-1";
679
                for (int i = 1; i < array.Length; i++)
680
                {
681
                    string name = array[i];
682
                    string uid = Guid.NewGuid().ToString();
683
                    DataRow[] rows = dt.Select(string.Format("LEVEL = '{0}' AND NAME = '{1}' AND PARENTID = '{2}'", i, name, prevId));
684
                    if (rows.Length == 0)
685
                        dt.Rows.Add(i, uid, prevId, name);
686
                    else
687
                        uid = rows[0]["SP_ID"].ToString();
688
                    prevId = uid;
689
                }
690
            }
691

  
692
            dt.Columns.Remove("LEVEL");
693

  
694
            ReleaseCOMObjects(units);
695
            ReleaseCOMObjects(dataSource);
696

  
697
            return dt;
698
        }
699
        public static string T_OPTIONSETTING_Value(string name)
700
        {
701
            string result = string.Empty;
702
            LMADataSource dataSource = new LMADataSource();
703
            LMOptionSettings settings = new LMOptionSettings();
704

  
705
            LMAFilter filter = new LMAFilter();
706
            LMACriterion criterion = new LMACriterion();
707
            filter.ItemType = "OptionSetting";
708
            criterion.SourceAttributeName = "NAME";
709
            criterion.Operator = "=";
710
            criterion.set_ValueAttribute(name);
711
            filter.get_Criteria().Add(criterion);
712
            settings.Collect(dataSource, Filter: filter);
713

  
714
            foreach (LMOptionSetting item in settings)
715
            {
716
                result = item.get_Value();
717
                break;
718
            }
719

  
720
            ReleaseCOMObjects(criterion);
721
            ReleaseCOMObjects(filter);
722
            ReleaseCOMObjects(settings);
723
            ReleaseCOMObjects(dataSource);
724
            return result;
725
        }
726

  
727
        public static void ReleaseCOMObjects(params object[] objVars)
728
        {
729
            int intNewRefCount = 0;
730
            foreach (object obj in objVars)
731
            {
732
                if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj))
733
                    intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
734
            }
735
        }
641 736
    }
642 737
}

내보내기 Unified diff

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