-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowForm.cs
More file actions
227 lines (203 loc) · 8.63 KB
/
WindowForm.cs
File metadata and controls
227 lines (203 loc) · 8.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
using EPDM.Interop.epdm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Windows.Forms;
namespace SWPDM_Update_Card_Data
{
public partial class WindowForm : Form
{
/// <summary>
///
/// </summary>
#region Private Variables
private Dictionary<string, string> Parameters = new Dictionary<string, string>();
private Dictionary<string, string>[] ParametersArray;
private readonly string[] Field = { "Center of Web", "Description", "Probe", "Tip", "Total Length", "Dut Plunger", "Preload", "Tip Extension", "Center-Top MGP", "Center-Bottom MGP" };
private UpdateProbeParameter swPDMAddin;
private UndoCheckoutFiles UndoCheckOut;
#endregion
/// <summary>
///
/// </summary>
/// <param name="swAddin"></param>
public WindowForm(UpdateProbeParameter swAddin)
{
InitializeComponent();
swPDMAddin = swAddin;
if (swPDMAddin.GetPpoData.Count == 1)
{
this.label11.Text = swPDMAddin.GetPpoData.Values.ElementAt(0);
ParametersArray = null;
}
else
{
ParametersArray = new Dictionary<string, string>[swPDMAddin.GetPpoData.Count];
}
}
#region Public Methods
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateCardData_button_Click(object sender, EventArgs e)
{
Parameters.Clear();
switch (this.tabControl.SelectedTab.Text)
{
case "Way 1":
if (HasData(CenterOfWeb_textBox.Text)==true &&
HasData(Description_textBox.Text)==true &&
HasData(Probe_textBox.Text) == true &&
HasData(TipType_textBox.Text) == true &&
HasData(TotalLength_textBox.Text) == true &&
HasData(DutPlunger_textBox.Text) == true &&
HasData(Preload_textBox.Text) == true &&
HasData(TipExtension_textBox.Text) == true &&
HasData(CenterTopMGP_textBox.Text) == true &&
HasData(CenterBottom_textBox.Text) == true)
{
if (swPDMAddin.GetPpoData.Count == 1) // If you choose one probe.
{
// Get Center of Web
Parameters.Add(Field[0], CenterOfWeb_textBox.Text);
// Get Desciption
Parameters.Add(Field[1], Description_textBox.Text);
// Get Probe type
Parameters.Add(Field[2], Probe_textBox.Text);
// Get Tip type
Parameters.Add(Field[3], TipType_textBox.Text);
// Get Total Length
Parameters.Add(Field[4], TotalLength_textBox.Text);
// Get Dut Plunger
Parameters.Add(Field[5], DutPlunger_textBox.Text);
// Get Preload
Parameters.Add(Field[6], Preload_textBox.Text);
// Get Tip Extension
Parameters.Add(Field[7], TipExtension_textBox.Text);
// Get Center-Top MGP
Parameters.Add(Field[8], CenterTopMGP_textBox.Text);
// Get Center-Bottom MGP
Parameters.Add(Field[9], CenterBottom_textBox.Text);
// Get Card Data
UpdateCardData(ref Parameters);
}
else // If you choose two or more probes.
{
tabControl.SelectedTab = Way2_tab;
}
}
else
{
MessageBox.Show("Please fill data into the textboxes below");
}
break;
case "Way 2":
string content = PasteFromClipboard_richTextBox.Text;
if (!String.IsNullOrEmpty(content) && content != "")
{
UpdateCardData(ref ParametersArray); // for single and multi probes.
}
else
{
MessageBox.Show("Please paste data into textbox below or move to | Way 1 | tab.");
}
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Cancel_button_Click(object sender, EventArgs e)
{
swPDMAddin = null;
Parameters = null;
Close();
}
/// <summary>
///
/// </summary>
/// <param name="Parameters"></param>
public void UpdateCardData(ref Dictionary<string, string> Parameters)
{
try
{
#region Local Variables
IEdmVault5 MyVault = swPDMAddin.GetVault5;
IEdmFile5 file;
Dictionary<int, string> ppoData = new Dictionary<int, string>();
int lParentFolderID = swPDMAddin.GetParentFolderID;
int lParentWnd = swPDMAddin.GetParentWnd;
#endregion
PasteFromClipboard_richTextBox.Text = "";
ppoData = swPDMAddin.GetPpoData;
foreach (KeyValuePair<int, string> p in ppoData){
// Get file
file = (IEdmFile5)MyVault.GetObject(EdmObjectType.EdmObject_File, p.Key);
// Check out this file
file.LockFile(lParentFolderID, this.Handle.ToInt32());
// Prepair if error happends
UndoCheckOut = new UndoCheckoutFiles(MyVault, p.Key, swPDMAddin.GetParentFolderID, this.Handle.ToInt32());
// Update variables
IEdmEnumeratorVariable5 vars = (IEdmEnumeratorVariable5)file.GetEnumeratorVariable(file.GetLocalPath(swPDMAddin.GetParentFolderID));
IEdmStrLst5 ConfigNames = (IEdmStrLst5)file.GetConfigurations();
// Get Po
IEdmPos5 pos = ConfigNames.GetHeadPosition();
string CurConfig = "";
while (!pos.IsNull){
CurConfig = ConfigNames.GetNext(pos);
for (int i = 0; i < Parameters.Count; i++){
vars.SetVar(Field[i], CurConfig, Parameters[Field[i]]);
}
}
//Close the file that is openning for access by this interface.
IEdmEnumeratorVariable8 vars8 = (IEdmEnumeratorVariable8)vars;
vars8.CloseFile(true);
// Check in this file
file.UnlockFile(this.Handle.ToInt32(), "Update card data and properties");
MessageBox.Show("Completed!");
Close();
}
}
catch (System.Runtime.InteropServices.COMException ex)
{
// Show error content
MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
// Undo check out file if error
UndoCheckOut.Undo();
}
catch (Exception ex)
{
// Show error content
MessageBox.Show(ex.Message + "\nUndo Check Out!!!");
// Undo check out file if error
UndoCheckOut.Undo();
}
// Delete object
UndoCheckOut = null;
}
/// <summary>
///
/// </summary>
/// <param name="ParametersArray"></param>
public void UpdateCardData(ref Dictionary<string, string>[] ParametersArray)
{
MessageBox.Show("Debug only, " + ParametersArray.ToString());
}
/// <summary>
///
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool HasData(string s)
{
if (!string.IsNullOrEmpty(s) && s != "") return true;
return false;
}
#endregion
}
}