@@ -170,11 +170,19 @@ private void BtnTransferData_Click(object sender, EventArgs e)
170
170
{
171
171
if ( AdditionalConnectionDetails . Count > 0 )
172
172
{
173
+ if ( BtnTransferData . Text == "Cancel" )
174
+ {
175
+ _transferOperation . KeepRunning = false ;
176
+ BtnTransferData . Enabled = false ;
177
+ BtnTransferData . Text = "Transfer Data" ;
178
+ return ;
179
+ }
173
180
InitializeLog ( ) ;
174
181
_transferOperation . KeepRunning = true ;
175
182
bool isErrorOccured = false ;
176
183
List < string > fetchXmls = new List < string > ( ) ;
177
184
List < int > tableIndexesForTransfer = new List < int > ( ) ;
185
+ BtnTransferData . Text = "Cancel" ;
178
186
179
187
foreach ( DataGridViewRow row in FetchDataGridView . Rows )
180
188
{
@@ -229,12 +237,16 @@ private void BtnTransferData_Click(object sender, EventArgs e)
229
237
}
230
238
fetchXmls . Clear ( ) ;
231
239
SetLoadingDetails ( false ) ;
240
+ BtnTransferData . Text = "Transfer Data" ;
232
241
if ( isErrorOccured )
233
242
LblInfo . Text = string . Empty ;
234
243
else if ( _transferOperation . KeepRunning && ! isErrorOccured )
235
244
MessageBox . Show ( "Data Migration Completed." , "Data Migration Completed" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
236
245
else
246
+ {
247
+ BtnTransferData . Enabled = true ;
237
248
MessageBox . Show ( "Migration is Stopped." , "Migration is Stopped" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
249
+ }
238
250
}
239
251
}
240
252
} ) ;
@@ -273,7 +285,6 @@ private void SetLoadingDetails(bool visible)
273
285
}
274
286
LblLoading . Visible = visible ;
275
287
LblTitle . Visible = visible ;
276
- pictureBoxStop . Visible = visible ;
277
288
}
278
289
279
290
private void InitializeLog ( )
@@ -284,10 +295,11 @@ private void InitializeLog()
284
295
285
296
private void ChangeToolsState ( bool state )
286
297
{
298
+ //richTextBoxLogs.Enabled = state;
287
299
pictureBoxRecBin . Enabled = state ;
288
300
TxtLogsPath . Enabled = state ;
289
301
BtnBrowseLogs . Enabled = state ;
290
- BtnTransferData . Enabled = state ;
302
+ // BtnTransferData.Enabled = state;
291
303
BtnSelectTargetInstance . Enabled = state ;
292
304
FetchDataGridView . Enabled = state ;
293
305
pictureBoxAdd . Enabled = state ;
@@ -298,6 +310,8 @@ private void PictureBoxRecBin_Click(object sender, EventArgs e)
298
310
_errorIndexes . Clear ( ) ;
299
311
_errorPosition = 0 ;
300
312
richTextBoxLogs . Text = null ;
313
+ LblInfo . Text = string . Empty ;
314
+ LblErrorText . Text = string . Empty ;
301
315
}
302
316
303
317
private void PictureBoxAdd_Click ( object sender , EventArgs e )
@@ -311,46 +325,55 @@ private void PopupDialog(int rowIndex = -1)
311
325
{
312
326
if ( _popup . ShowDialog ( ) == DialogResult . OK )
313
327
{
314
- try
328
+ WorkAsync ( new WorkAsyncInfo
315
329
{
316
- _dataverseService = new DataverseService ( Service ) ;
317
- string fetch = _popup . TextBoxFetch . Text ;
318
-
319
- if ( rowIndex != - 1 && fetch == _popup . FetchXmls [ rowIndex ] )
320
- {
321
- return ;
322
- }
323
- string displayName = _dataverseService . GetDisplayName ( fetch ) ;
324
- string logicalName = _dataverseService . GetLogicalName ( fetch ) ;
325
-
326
- if ( rowIndex != - 1 )
330
+ Message = "Loading..." ,
331
+ Work = ( worker , args ) =>
327
332
{
328
- _popup . FetchXmls [ rowIndex ] = fetch ;
329
- fetchXmlDataBindingSource [ rowIndex ] = new FetchXmlData ( )
333
+ try
330
334
{
331
- DisplayName = displayName ,
332
- SchemaName = logicalName
333
- } ;
334
- _displayNames [ rowIndex ] = displayName ;
335
- }
336
- else
337
- {
338
- _displayNames . Add ( displayName ) ;
339
- fetchXmlDataBindingSource . Add ( new FetchXmlData ( )
335
+ ChangeToolsState ( false ) ;
336
+ _dataverseService = new DataverseService ( Service ) ;
337
+ string fetch = _popup . TextBoxFetch . Text ;
338
+
339
+ if ( rowIndex != - 1 && fetch == _popup . FetchXmls [ rowIndex ] )
340
+ {
341
+ return ;
342
+ }
343
+ string displayName = _dataverseService . GetDisplayName ( fetch ) ;
344
+ string logicalName = _dataverseService . GetLogicalName ( fetch ) ;
345
+
346
+ if ( rowIndex != - 1 )
347
+ {
348
+ _popup . FetchXmls [ rowIndex ] = fetch ;
349
+ fetchXmlDataBindingSource [ rowIndex ] = new FetchXmlData ( )
350
+ {
351
+ DisplayName = displayName ,
352
+ SchemaName = logicalName
353
+ } ;
354
+ _displayNames [ rowIndex ] = displayName ;
355
+ }
356
+ else
357
+ {
358
+ _displayNames . Add ( displayName ) ;
359
+ fetchXmlDataBindingSource . Add ( new FetchXmlData ( )
360
+ {
361
+ DisplayName = displayName ,
362
+ SchemaName = logicalName
363
+ } ) ;
364
+ }
365
+ }
366
+ catch ( Exception ex )
340
367
{
341
- DisplayName = displayName ,
342
- SchemaName = logicalName
343
- } ) ;
344
- }
345
- }
346
- catch ( Exception ex )
347
- {
348
- if ( rowIndex == - 1 )
349
- {
350
- _popup . FetchXmls . RemoveAt ( _popup . FetchXmls . Count - 1 ) ;
368
+ if ( rowIndex == - 1 )
369
+ {
370
+ _popup . FetchXmls . RemoveAt ( _popup . FetchXmls . Count - 1 ) ;
371
+ }
372
+ MessageBox . Show ( $ "{ ex . Message } .", "Error Message" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
373
+ }
374
+ ChangeToolsState ( true ) ;
351
375
}
352
- MessageBox . Show ( $ "{ ex . Message } .", "Error Message" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
353
- }
376
+ } ) ;
354
377
}
355
378
}
356
379
@@ -375,11 +398,6 @@ private void FetchDataGridView_CellContentClick(object sender, DataGridViewCellE
375
398
}
376
399
}
377
400
378
- private void PictureBoxStop_Click ( object sender , EventArgs e )
379
- {
380
- _transferOperation . KeepRunning = false ;
381
- }
382
-
383
401
private void RichTextBoxLogs_TextChanged ( object sender , EventArgs e )
384
402
{
385
403
FindErrorIndexes ( ) ;
0 commit comments