| Line 112... |
Line 112... |
| 112 |
} |
112 |
} |
| 113 |
} |
113 |
} |
| 114 |
|
114 |
|
| 115 |
void EditRecord_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
115 |
void EditRecord_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
| 116 |
{ |
116 |
{ |
| - |
|
117 |
if (e.Error == null) |
| - |
|
118 |
{ |
| 117 |
this.DialogResult = DialogResult.OK; |
119 |
this.DialogResult = DialogResult.OK; |
| 118 |
this.Close(); |
120 |
this.Close(); |
| - |
|
121 |
} |
| - |
|
122 |
else |
| - |
|
123 |
{ |
| - |
|
124 |
if (e.Error.Message == "internal_error_could_not_destroy_record" |
| - |
|
125 |
|| e.Error.Message == "internal_error_could_not_update_zone") |
| - |
|
126 |
{ |
| - |
|
127 |
if (MessageBox.Show("An internal error has occurred.", "DNS Manager", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) |
| - |
|
128 |
{ |
| - |
|
129 |
this.EditRecord.RunWorkerAsync(this.BuildRecord()); |
| - |
|
130 |
return; |
| - |
|
131 |
} |
| - |
|
132 |
} |
| - |
|
133 |
else if (e.Error.Message.Contains("invalid_value")) |
| - |
|
134 |
{ |
| - |
|
135 |
MessageBox.Show("This value is invalid:\n" + |
| - |
|
136 |
e.Error.Message.Replace("invalid_value\t", "").CapitaliseFirstLetter() |
| - |
|
137 |
+ "\nThe previous record has been deleted.", "DNS Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); |
| - |
|
138 |
|
| - |
|
139 |
this.IsEdit = false; |
| - |
|
140 |
this.textBoxRecord.Enabled = true; |
| - |
|
141 |
this.comboBoxType.Enabled = true; |
| - |
|
142 |
} |
| - |
|
143 |
|
| - |
|
144 |
this.buttonSave.Enabled = true; |
| - |
|
145 |
this.buttonCancel.Enabled = true; |
| - |
|
146 |
this.textBoxComment.Enabled = true; |
| - |
|
147 |
this.textBoxValue.Enabled = true; |
| - |
|
148 |
} |
| 119 |
} |
149 |
} |
| 120 |
|
150 |
|
| 121 |
void AddRecord_DoWork(object sender, DoWorkEventArgs e) |
151 |
void AddRecord_DoWork(object sender, DoWorkEventArgs e) |
| 122 |
{ |
152 |
{ |
| 123 |
this.API.DNS.AddRecord((DNSRecord)e.Argument); |
153 |
this.API.DNS.AddRecord((DNSRecord)e.Argument); |
| Line 125... |
Line 155... |
| 125 |
} |
155 |
} |
| 126 |
|
156 |
|
| 127 |
void EditRecord_DoWork(object sender, DoWorkEventArgs e) |
157 |
void EditRecord_DoWork(object sender, DoWorkEventArgs e) |
| 128 |
{ |
158 |
{ |
| 129 |
this.API.DNS.RemoveRecord(this.Record); |
159 |
this.API.DNS.RemoveRecord(this.Record); |
| - |
|
160 |
|
| 130 |
System.Threading.Thread.Sleep(3000); |
161 |
string[] retryErrors = { |
| - |
|
162 |
"CNAME_must_be_only_record", |
| - |
|
163 |
"CNAME_already_on_record", |
| - |
|
164 |
"record_already_exists_remove_first", |
| - |
|
165 |
"internal_error_updating_zone", |
| - |
|
166 |
"internal_error_could_not_load_zone", |
| - |
|
167 |
"internal_error_could_not_add_record" |
| - |
|
168 |
}; |
| - |
|
169 |
|
| - |
|
170 |
bool finish = false; |
| - |
|
171 |
|
| - |
|
172 |
while (!finish) |
| - |
|
173 |
{ |
| - |
|
174 |
try |
| - |
|
175 |
{ |
| 131 |
this.API.DNS.AddRecord((DNSRecord)e.Argument); |
176 |
this.API.DNS.AddRecord((DNSRecord)e.Argument); |
| - |
|
177 |
finish = true; |
| - |
|
178 |
} |
| - |
|
179 |
catch (Exception x) |
| - |
|
180 |
{ |
| - |
|
181 |
if (!retryErrors.Contains(x.Message)) |
| - |
|
182 |
{ |
| - |
|
183 |
throw x; |
| - |
|
184 |
} |
| - |
|
185 |
} |
| - |
|
186 |
} |
| - |
|
187 |
|
| 132 |
System.Threading.Thread.Sleep(3000); |
188 |
System.Threading.Thread.Sleep(3000); |
| 133 |
} |
189 |
} |
| 134 |
|
190 |
|
| 135 |
private void buttonSave_Click(object sender, EventArgs e) |
191 |
private void buttonSave_Click(object sender, EventArgs e) |
| 136 |
{ |
192 |
{ |