프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter_AutoModeling / MainControl.cs @ b8ff72eb

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

1 f2151e28 gaqhf
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Drawing;
5
using System.Data;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10 2cae7d1f gaqhf
using Microsoft.Win32;
11
using Telerik.WinControls.UI;
12
using System.IO;
13
using System.Threading;
14
using SPPID.Modeling;
15
using SPPID.Model;
16
using SPPID.Utill;
17 e9718eec gaqhf
using Microsoft.VisualBasic;
18 f2151e28 gaqhf
19
namespace SPPIDConverter_AutoModeling
20
{
21
    public partial class MainControl : UserControl
22
    {
23 2cae7d1f gaqhf
        private Dictionary<string, string> symbolMapping = new Dictionary<string, string>();
24
        private Dictionary<string, string> attributeMapping = new Dictionary<string, string>();
25
        Thread autoModelingThread;
26
27 f2151e28 gaqhf
        public MainControl()
28
        {
29
            InitializeComponent();
30 2cae7d1f gaqhf
            SetPath();
31
        }
32
33
        private void btnLoadFiles_Click(object sender, EventArgs e)
34
        {
35
            OpenFileDialog dia = new OpenFileDialog();
36
            dia.Multiselect = true;
37
            dia.Filter = "Xml Files(*.xml)|*.xml";
38
            if (dia.ShowDialog() == DialogResult.OK)
39
            {
40
                SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
41
42
                foreach (string fileName in dia.FileNames)
43
                {
44
                    GridViewDataRowInfo row = new GridViewDataRowInfo(gridViewDrawingList.MasterView);
45
                    Document document = Document.Load(fileName, symbolMapping, attributeMapping);
46
47
                    row.Cells["colCheckBox"].Value = false;
48
                    row.Cells["colDrawingName"].Value = fileName;
49
                    row.Cells["colStatus"].Value = "Ready";
50
                    row.Cells["colDrawingFullName"].Value = fileName;
51
                    gridViewDrawingList.Rows.Add(row);
52
                }
53
            }
54
        }
55
56
        private void SetPath()
57
        {
58
            try
59
            {
60
                RegistryKey key = Registry.LocalMachine;
61
                RegistryKey software = key.OpenSubKey("SOFTWARE");
62
                RegistryKey DOFTECH = software.OpenSubKey("DOFTECH");
63
                if (DOFTECH != null)
64
                {
65
                    RegistryKey ID2 = DOFTECH.OpenSubKey("ID2");
66
                    if (ID2 != null)
67
                    {
68
                        SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString();
69
                        Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log";
70
                        SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml";
71
                    }
72
                }
73
            }
74
            catch (Exception ex)
75
            {
76
77
            }
78 f2151e28 gaqhf
        }
79 e9718eec gaqhf
80
        private void btnRun_Click(object sender, EventArgs e)
81
        {
82
            try
83
            {
84
                dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
85 ec0ff05a gaqhf
                for (int i = 0; i < 4; i++)
86
                {
87
                    dynamic newDrawing = application.Drawings.Add("PA", @"\\server70\DOFTECHSITE\P&ID Reference Data\Template Files\STIM A1.pid", "Test" + i, "Test" + i);
88
                    application.ActiveWindow.Fit();
89
                    Thread.Sleep(10);
90
                    application.ActiveWindow.Zoom = 2000;
91
                    Thread.Sleep(10);
92
93
94
95
96
97
                    newDrawing.CloseDrawing(true);
98
                    application.ActiveWindow.Fit();
99
                    Thread.Sleep(10);
100
                }
101 e9718eec gaqhf
102 ec0ff05a gaqhf
                //MessageBox.Show("End");
103 e9718eec gaqhf
            }
104
            catch (Exception ex)
105
            {
106
                MessageBox.Show(ex.Message);
107
            }
108
        }
109 f2151e28 gaqhf
    }
110
}
클립보드 이미지 추가 (최대 크기: 500 MB)