개정판 465c8b6e
dev issue #1223 : add Log
Change-Id: I347b0bd0f70f1a50e62cf9dbe65b6470eead4a25
DTI_PID/APIDConverter/AVEVA.PID.CustomizationUtility_ACAD2018_x64.csproj | ||
---|---|---|
114 | 114 |
<Compile Include="Form\ProjectForm.Designer.cs"> |
115 | 115 |
<DependentUpon>ProjectForm.cs</DependentUpon> |
116 | 116 |
</Compile> |
117 |
<Compile Include="Log.cs" /> |
|
117 | 118 |
<Compile Include="Model\PlantItem\EndBreak.cs" /> |
118 | 119 |
<Compile Include="Model\PlantItem\LineNumber.cs" /> |
119 | 120 |
<Compile Include="Model\PlantItem\Other\APIDInfo.cs" /> |
DTI_PID/APIDConverter/DB/Project_DB.cs | ||
---|---|---|
49 | 49 |
} |
50 | 50 |
catch (Exception ex) |
51 | 51 |
{ |
52 |
//Log.Write(ex.Message + "\r\n" + ex.StackTrace);
|
|
52 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
53 | 53 |
if (connection != null) |
54 | 54 |
connection.Dispose(); |
55 | 55 |
connection = null; |
... | ... | |
81 | 81 |
} |
82 | 82 |
catch (Exception ex) |
83 | 83 |
{ |
84 |
//Log.Write(ex.Message + "\r\n" + ex.StackTrace);
|
|
84 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
85 | 85 |
} |
86 | 86 |
finally |
87 | 87 |
{ |
... | ... | |
106 | 106 |
} |
107 | 107 |
catch (Exception ex) |
108 | 108 |
{ |
109 |
//Log.Write(ex.Message + "\r\n" + ex.StackTrace);
|
|
109 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
110 | 110 |
} |
111 | 111 |
finally |
112 | 112 |
{ |
... | ... | |
118 | 118 |
|
119 | 119 |
return result; |
120 | 120 |
} |
121 |
|
|
121 |
|
|
122 |
public static DataTable SelectID2SymbolTable() |
|
123 |
{ |
|
124 |
DataTable dt = new DataTable(); |
|
125 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
126 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
|
127 |
{ |
|
128 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
129 |
{ |
|
130 |
try |
|
131 |
{ |
|
132 |
connection.Open(); |
|
133 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
134 |
{ |
|
135 |
cmd.CommandText = @"SELECT * FROM Symbol"; |
|
136 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
137 |
dt.Load(dr); |
|
138 |
} |
|
139 |
connection.Close(); |
|
140 |
} |
|
141 |
catch (Exception ex) |
|
142 |
{ |
|
143 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
144 |
} |
|
145 |
finally |
|
146 |
{ |
|
147 |
connection.Dispose(); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
else if (projectInfo.DBType == ID2DB_Type.MSSQL) |
|
152 |
{ |
|
153 |
using (SqlConnection connection = GetSqlConnection()) |
|
154 |
{ |
|
155 |
try |
|
156 |
{ |
|
157 |
if (connection != null && connection.State == ConnectionState.Open) |
|
158 |
{ |
|
159 |
using (SqlCommand cmd = connection.CreateCommand()) |
|
160 |
{ |
|
161 |
cmd.CommandText = @"SELECT * FROM Symbol"; |
|
162 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
|
163 |
dt.Load(dr); |
|
164 |
} |
|
165 |
connection.Close(); |
|
166 |
} |
|
167 |
} |
|
168 |
catch (Exception ex) |
|
169 |
{ |
|
170 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
171 |
} |
|
172 |
finally |
|
173 |
{ |
|
174 |
if (connection != null) |
|
175 |
connection.Dispose(); |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
return dt; |
|
181 |
} |
|
182 |
|
|
122 | 183 |
} |
123 | 184 |
} |
DTI_PID/APIDConverter/Form/APIDConverter.cs | ||
---|---|---|
20 | 20 |
InitializeComponent(); |
21 | 21 |
} |
22 | 22 |
|
23 |
DataTable ID2SymbolTypeTable = null; |
|
24 |
|
|
23 | 25 |
private void btnLoadFile_Click(object sender, EventArgs e) |
24 | 26 |
{ |
25 | 27 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
... | ... | |
33 | 35 |
{ |
34 | 36 |
foreach (var fileName in dia.FileNames) |
35 | 37 |
{ |
36 |
//Document document = new Document(fileName, ); |
|
38 |
Document document = new Document(fileName, ID2SymbolTypeTable); |
|
39 |
|
|
37 | 40 |
} |
38 | 41 |
} |
39 | 42 |
} |
... | ... | |
45 | 48 |
{ |
46 | 49 |
MessageBox.Show("Check Project Setting!", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
47 | 50 |
} |
51 |
else |
|
52 |
{ |
|
53 |
ID2SymbolTypeTable = Project_DB.SelectID2SymbolTable(); |
|
54 |
} |
|
48 | 55 |
} |
49 | 56 |
} |
50 | 57 |
} |
DTI_PID/APIDConverter/Log.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
using System.IO; |
|
7 |
|
|
8 |
namespace AVEVA.PID.CustomizationUtility |
|
9 |
{ |
|
10 |
public static class Log |
|
11 |
{ |
|
12 |
private static readonly string Path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\SPPID Converter.log"; |
|
13 |
|
|
14 |
public static void Write(string text) |
|
15 |
{ |
|
16 |
using (StreamWriter sw = File.AppendText(Path)) |
|
17 |
{ |
|
18 |
sw.WriteLine(text); |
|
19 |
sw.Close(); |
|
20 |
sw.Dispose(); |
|
21 |
} |
|
22 |
} |
|
23 |
} |
|
24 |
} |
내보내기 Unified diff